 # How to make two different sizes of feature map have the same size with bigger size?

First feature map is 150x150, I use convolution with stride=2, and then deconvolution with scale=2, the feature map size is 148x148. How can I make 148x148 be 150x150? And then I use mx.symbol.Crop, in module.fit(), after executing self.forward(), there are error in self.update(). The error is the following :

/home/travis/build/dmlc/mxnet-distro/mxnet-build/dmlc-core/include/dmlc/logging.h:308: [11:17:01] src/operator/./crop-inl.h:126: Check failed: data_shape >= out_shape (148 vs. 150) data_shape’height should be larger than that of out_shape

Any advice will be appreciated. Thank you very much!

see `padding` parameter.

In your case, try `padding=(1,1)`.

If that doesn’t work, please post a minimally reproducible example and I will try to help you further.

1 Like

Hi, according to the documentation the new dimensions are related with the old dimensions with the following formula:

``````out_height = floor((height+2*padding-dilation*(kernel_size-1)-1)/stride)+1
If you fix some of the parameters, and demand `out_height==height=h` (same for width) you can evaluate the rest parameter values so as sto have padding = ‘SAME’. Solving for padding, `p`, (for ODD kernels!):
``````p = (1-d-h+d*k+h*s)/2
where p: padding, d: dilation rate, h:height, k:kernel size. For example, for dilation = 1, and stride = 2, and kernel=3, we get `p=(3+h)/2`. Same rule holds for transpose convolution as well (deconvolution). Therefore, select some of the p,k,d,s and solve for the other according to the input = output you have.