Sha*_*ban 2 tensorflow deconvolution
我试图tf.nn.deconv2d()在可变大小的数据批处理上使用op.但是,似乎我需要将output_shape参数设置如下:
tf.nn.deconv2d(x, filter, output_shape=[12, 24, 24, 5], strides=[1, 2, 2, 1],
padding="SAME")
Run Code Online (Sandbox Code Playgroud)
为什么tf.nn.deconv2d()要修一个output_shape?有没有办法指定变量批量维度?如果输入批量大小变化会发生什么?
NB tf.nn.deconv2d()将tf.nn.conv2d_transpose()在下一版TensorFlow(0.7.0)中调用.
的output_shape到参数tf.nn.deconv2d()接受一个计算Tensor作为其值,这使得指定一个动态形状.例如,假设您的输入定义如下:
# N.B. Other dimensions are chosen arbitrarily.
input = tf.placeholder(tf.float32, [None, 24, 24, 5])
Run Code Online (Sandbox Code Playgroud)
...然后可以在运行时计算特定步骤的批量大小:
batch_size = tf.shape(input)[0]
Run Code Online (Sandbox Code Playgroud)
使用此值,您可以构建output_shape参数以tf.nn.deconv2d()使用tf.pack():
output_shape = tf.pack([batch_size, 24, 24, 5])
result = tf.nn.deconv2d(..., filter, output_shape=output_shape,
strides=[1, 2, 2, 1], padding='SAME')
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1346 次 |
| 最近记录: |