Whether can remove caffeMode.
Created by: hedaoyuan
In Paddle's code, caffeMode
is a value of type bool (ConvBaseLayer::caffeMode_ and caffe_mode). Set to true or false, will affect the output size of the convolution calculation (outputSize and cnn_output_size).
The calculation result when caffeMode is set to false or true is as follows.
/**
* Calculate output size based on caffeMode_.
* - input(+padding): 0123456789
* - imageSize(+padding) = 10;
* - filterSize = 3;
* - stride = 2;
* - caffeMode is true:
- output: (012), (234), (456), (678)
- outputSize = 4;
* - caffeMode is false:
* - output: (012), (234), (456), (678), (9)
* - outputSize = 5;
*/
int outputSize(int imageSize, int filterSize, int padding, int stride, bool caffeMode) {
int outputSize;
if (!caffeMode) {
outputSize = (imageSize - filterSize + 2 * padding + stride - 1) / stride + 1;
} else {
outputSize = (imageSize - filterSize + 2 * padding) / stride + 1;
}
return outputSize;
}
- The two modes are not the same in some cases.
-
caffeMode = true
refers to the calculation method in caffe. This method is also used in cudnn. So, if the convolution layer is configured as cudnn, you need to ensure thatcaffe_mode = True
. - If the
padding
is replaced withpaddingLeft
andpaddingRight
two arguments. IncaffeMode = true
formula, modify the size of the padding can also achievecaffeMode = false
results.
So, can we remove this configuration argument?