-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Add {valid, full} option for Pooling layer #3392
Conversation
1) default pooling option is valid. 2) if model is from caffe, same option for pooling layer will be on.
Why call it |
@sxjscience |
@Darwin2011 Could we manually adjust the padding to achieve the similar result? |
@sxjscience Could you please explain a little bit more? Thanks. |
@Darwin2011 I'm not sure whether this will break the C++ implementations. |
@antinucleon @piiswrong @winstywang What do you think about this? Some old caffemodels like VGG_CNN_M requires this type of compatible pooling. Another solution is to fine-tune these networks using the revised structure (pad 1 in the pooling layer) and add them to our own model zoo. |
@sxjscience |
@Darwin2011 Yes, this is a problem. One way to deal with the problem is to add |
@sxjscience Thanks. |
I think this should be added. Although the name "same" sounds cryptic. How about "compatible"? BTW, put kValid first in the enum |
@@ -25,13 +25,15 @@ namespace pool_enum { | |||
enum PoolingOpInputs {kData}; | |||
enum PoolingOpOutputs {kOut}; | |||
enum PoolingOpType {kMaxPooling, kAvgPooling, kSumPooling}; | |||
enum PoolingOpPadConventionType {kSame, kValid}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put kValid first
@@ -47,6 +49,11 @@ struct PoolingParam : public dmlc::Parameter<PoolingParam> { | |||
.add_enum("avg", pool_enum::kAvgPooling) | |||
.add_enum("sum", pool_enum::kSumPooling) | |||
.describe("Pooling type to be applied."); | |||
|
|||
DMLC_DECLARE_FIELD(pad_convention).set_default(pool_enum::kValid) | |||
.add_enum("same", pool_enum::kSame) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change same to "full" or "compatible" and add document describing the difference (round up or down, discard extra or pad zero) and say that use full for compatibility with caffe
@piiswrong @Darwin2011 @sxjscience: These names are really bad. In the literature, 'same', 'valid' and 'full' have precise meanings for pooling and convolutions:
This is used by TensorFlow or Numpy, for example. Using these names for this will cause confusion (esp. if MXnet decided to add these very useful options for convolution + pooling). One option: have a "caffe_compatibility" (bool) option. Here is a question that we should answer first: what is the actual computational difference in the pooling layer? Is the MXNet pooling layer equivalent to Caffe with some extra padding for certain input dimensions? If so, we can fix this at the Caffe importer level rather than hacking it into the MXNet pooling definition. |
the difference is basically round down vs up in division. So valid makes On Sep 30, 2016 4:16 AM, "Sebastian Bodenstein" [email protected]
|
add some description
@sbodenstein Thanks for your advice. |
Thanks a lot for your review, @piiswrong |
@Darwin2011 I think we can merge this in if the test passes. |
please update |
Mxnet's pooling layer's output doesn't match Caffe's pooling's output, although Mxnet's convolution layer's output shape is same as Caffe. This issue will cause Googlenet from caffe convertor failing.
The following links shows pooling output size formula.
for caffe,
https://github.com/BVLC/caffe/blob/master/src/caffe/layers/pooling_layer.cpp#L90
for mxnet,
https://github.com/dmlc/mxnet/blob/master/src/operator/pooling-inl.h#L202
And please see #2999. @winstywang @ChenFengAndy
So I add two options for pooling layer {valid, same}. valid is for current mxnet's pooling output and for caffe, it uses same option
Please give some comments. Thanks a lot.