using deconv2d instead of PS
huangzehao opened this issue · comments
Hi, I am trying to compare the performance of deconvolution and subpixel convolution. I change the generator by following:
`
def generator(self, z):
self.h0, self.h0_w, self.h0_b = deconv2d(z, [self.batch_size, 32, 32, self.gf_dim], k_h=1, k_w=1, d_h=1, d_w=1, name='g_h0', with_w=True)
h0 = lrelu(self.h0)
self.h1, self.h1_w, self.h1_b = deconv2d(h0, [self.batch_size, 32, 32, self.gf_dim], name='g_h1', d_h=1, d_w=1, with_w=True)
h1 = lrelu(self.h1)
h2, self.h2_w, self.h2_b = deconv2d(h1, [self.batch_size, 128, 128, 3], d_h=1, d_w=1, name='g_h2', with_w=True)
return tf.nn.tanh(h2)`
But it doesn't works:
Traceback (most recent call last): File "main.py", line 58, in <module> tf.app.run() File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 30, in run sys.exit(main(sys.argv[:1] + flags_passthrough)) File "main.py", line 42, in main dcgan.train(FLAGS) File "/home/zehaohuang/subpixel_sr/model.py", line 95, in train .minimize(self.g_loss, var_list=self.g_vars) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/optimizer.py", line 196, in minimize grad_loss=grad_loss) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/optimizer.py", line 253, in compute_gradients colocate_gradients_with_ops=colocate_gradients_with_ops) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gradients.py", line 491, in gradients in_grad.set_shape(t_in.get_shape()) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 408, in set_shape self._shape = self._shape.merge_with(shape) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/tensor_shape.py", line 583, in merge_with (self, other)) ValueError: Shapes (64, 128, 128, 64) and (64, 32, 32, 64) are not compatible
Is there something wrong in my changing?
BTW, h2 = tf.depth_to_space(h2, 4)
works well, 'PS' function can be replaced by 'tf.depth_to_space'!
Sorry, I know the problem. I should change 'stride' in 'deconv2d'.
@huangzehao, So how is the performance difference between deconvolution and subpixel convolution?