0

I have the following snippet of code to do deconv.

x.get_shape() gives me (?, 14, 14, 128)

self.w.get_shape() gives me (3, 3, 64, 128)

output_shape should be (?, 14, 14, 64)

filter size is [3, 3], stride is [1, 1, 1, 1] and padding is 'SAME'

but h.get_shape() gives me (?, ?, ?, 128) which I was expecting to see (?, 14, 14, 64).

Can you help me to spot where is the error?

                    print(x.get_shape())
                    print(self.w.get_shape())
                    output_shape = tf.pack([tf.shape(x)[0],
                                           self.output_size[0],
                                           self.output_size[1],
                                           self.output_size[2]])
                    h = self.activation(
                        tf.nn.bias_add(
                            tf.nn.conv2d_transpose(
                                x, self.w,
                                output_shape=output_shape,
                                strides=self.stride,
                                padding=self.padding
                            ), self.b
                        )
                    )
                    print(h.get_shape())
ATANG
  • 33
  • 4

1 Answers1

0

Weight variable for convolution should have a shape of [height, width, input_channels, output_channels]. Thus, just try to swap two last parameters of shape when creating self.w.

Dmitriy Danevskiy
  • 3,119
  • 1
  • 11
  • 15