# Tensorflow conv2d_transpose（deconv）out_backprop的行数与计算的不匹配

Kendall Weihe

...所以它减了1？

deconv代码如下所示：

``````temp_batch_size = tf.shape(x)[0]
# output_shape = tf.pack([temp_batch_size, 50, 50, 64])
output_shape = [temp_batch_size, 50, 50, 64]
conv4 = tf.nn.conv2d_transpose(conv3, weights['wdc1'], output_shape=output_shape, strides=[1,1,1,1], padding="VALID")
# conv4 = tf.nn.local_response_normalization(conv4)

# output_shape = tf.pack([temp_batch_size, 100, 100, 32])
output_shape = [temp_batch_size, 100, 100, 32]
conv5 = tf.nn.conv2d_transpose(conv4, weights['wdc2'], output_shape=output_shape, strides=[1,1,1,1], padding="VALID")
# conv5 = tf.nn.local_response_normalization(conv5)

# output_shape = tf.pack([temp_batch_size, 200, 200, 1])
output_shape = [temp_batch_size, 200, 200, 1]
conv6 = tf.nn.conv2d_transpose(conv5, weights['wdc3'], output_shape=output_shape, strides=[1,1,1,1], padding="VALID")
# conv6 = tf.nn.local_response_normalization(conv6)
``````

（你可以看到我尝试`tf.pack()`没有成功-如建议在这里），其中，权重分别是：

``````'wdc1' : tf.Variable(tf.random_normal([25, 25, 64,128])),

'wdc2' : tf.Variable(tf.random_normal([50, 50, 32,64])),

'wdc3' : tf.Variable(tf.random_normal([100, 100, 1,32])),
``````

``````(Pdb) conv3
<tf.Tensor 'MaxPool_2:0' shape=(?, 25, 25, 128) dtype=float32>
(Pdb) conv4
<tf.Tensor 'conv2d_transpose:0' shape=(?, ?, ?, ?) dtype=float32>
(Pdb) conv5
<tf.Tensor 'conv2d_transpose_1:0' shape=(?, ?, ?, ?) dtype=float32>
(Pdb) conv6
<tf.Tensor 'conv2d_transpose_2:0' shape=(?, ?, ?, ?) dtype=float32>
``````

``````(Pdb) conv4
<tf.Tensor 'conv2d_transpose:0' shape=(10, 50, 50, 64) dtype=float32>
(Pdb) conv5
<tf.Tensor 'conv2d_transpose_1:0' shape=(10, 100, 100, 32) dtype=float32>
(Pdb) conv6
<tf.Tensor 'conv2d_transpose_2:0' shape=(10, 200, 200, 1) dtype=float32>
``````

``````weights = {
'wdc1' : tf.Variable(tf.random_normal([3, 3, 64, 128])),
'wdc2' : tf.Variable(tf.random_normal([3, 3, 32, 64])),
'wdc3' : tf.Variable(tf.random_normal([3, 3, 1, 32]))
}
``````

``````temp_batch_size = 10

conv3 = tf.zeros([temp_batch_size, 25, 25, 128])
output_shape = [temp_batch_size, 50, 50, 64]
conv4 = tf.nn.conv2d_transpose(conv3, weights['wdc1'], output_shape=output_shape, strides=[1,2,2,1], padding="SAME")

output_shape = [temp_batch_size, 100, 100, 32]
conv5 = tf.nn.conv2d_transpose(conv4, weights['wdc2'], output_shape=output_shape, strides=[1,2,2,1], padding="SAME")

output_shape = [temp_batch_size, 200, 200, 1]
conv6 = tf.nn.conv2d_transpose(conv5, weights['wdc3'], output_shape=output_shape, strides=[1,2,2,1], padding="SAME")
``````

0条评论