3
$\begingroup$

I am trying to understand how the shape of the image changes after deconvolution ? I am trying to understand the example code of convolutional autoencoder from neon.

layers = [Conv((4, 4, 8), init=init_uni, activation=Rectlin()),
          Pooling(2),
          Conv((4, 4, 32), init=init_uni, activation=Rectlin()),
          Pooling(2),
          Deconv(fshape=(3, 3, 8), init=init_uni, strides=2, padding=1),
          Deconv(fshape=(3, 3, 8), init=init_uni, strides=2, padding=1),
          Deconv(fshape=(4, 4, 1), init=init_uni, strides=2, padding=0)]

The input_shapes and output_shapes of each layer are as follows

Convolution Layer 'ConvolutionLayer': 1 x (28x28) inputs, 8 x (25x25) outputs, padding 0, stride 1
Pooling Layer 'PoolingLayer': 8 x (25x25) inputs, 8 x (12x12) outputs
Convolution Layer 'ConvolutionLayer': 8 x (12x12) inputs, 32 x (9x9) outputs, padding 0, stride 1
Pooling Layer 'PoolingLayer': 32 x (9x9) inputs, 32 x (4x4) outputs
Deconvolution Layer 'DeconvolutionLayer': 32 x (4x4) inputs, 8 x (7x7) outputs
Deconvolution Layer 'DeconvolutionLayer': 8 x (7x7) inputs, 8 x (13x13) outputs
Deconvolution Layer 'DeconvolutionLayer': 8 x (13x13) inputs, 1 x (28x28) outputs

I understand how the shapes change after convolution ('valid'). (Thanks to http://cs231n.github.io/convolutional-networks/) How does the stride affect the size of matrix when deconvolution (full convolution) is used ?

$\endgroup$
2

2 Answers 2

1
$\begingroup$

The strided deconvolution is expanding the size of the layer (you can think of it as undo-ing the effect of the pooling without doing unpooling).

Check out slide 18 here. That might help.

$\endgroup$
1
$\begingroup$

Upsampling or deconvolution layer is used to increase the resolution of the image. In segmentation, we first downsample the image to get the features and then upsample the image to generate the segments.

For deconvolution operation we pad the image with zeroes and then do a convolution operation on that, hence it is upsampled.

For eg: - If after downsampling the images becomes [[1, 1] [1, 1]]

Then if we pad it with zeroes, [[0, 0, 0, 0, 0, 0] [0, 0, 0, 0, 0, 0] [0, 0, 1, 1, 0, 0] [0, 0, 1, 1, 0, 0] [0, 0, 0, 0, 0, 0] [0, 0, 0, 0, 0, 0]]

Now, if we do convolution on the above image with a 3 x 3 filter, we will get an image of shape (4, 4). Thus we upsampled an image of shape (2, 2) to (4, 4).

$\endgroup$
1
  • $\begingroup$ Is the upampled image like the input to the convolution? I mean is the reconstructed (4, 4) image like the original one? $\endgroup$ Commented Dec 23, 2017 at 12:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.