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[2] >= out_shape[2] (148 vs. 150) data_shape’height should be larger than that of out_shape
Any advice will be appreciated. Thank you very much!
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.
thanks for your advice. For my input images, the sizes are different, so I am sure how much I need add padding. For my solution, I dilate feature map to a constant size that is estimated to be larger than the size I need. And then I crop the dilated feature map to fit the size of a base feature map.
Thanks for your reply. I also see the equation from the document. My solution is to dilate feature map to a big size, and crop it to the size of a base feature map.