Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whether can remove caffeMode. #2460

Closed
hedaoyuan opened this issue Jun 14, 2017 · 2 comments
Closed

Whether can remove caffeMode. #2460

hedaoyuan opened this issue Jun 14, 2017 · 2 comments
Assignees

Comments

@hedaoyuan
Copy link
Contributor

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;
}
  1. The two modes are not the same in some cases.
  2. 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 that caffe_mode = True.
  3. If the padding is replaced with paddingLeft and paddingRight two arguments. In caffeMode = true formula, modify the size of the padding can also achieve caffeMode = false results.

So, can we remove this configuration argument?

@qingqing01
Copy link
Contributor

I think we can remove this argument and keep a standard format, the caffe_mode=True format.

@hedaoyuan
Copy link
Contributor Author

The code has been refactored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants