caffe2 icon indicating copy to clipboard operation
caffe2 copied to clipboard

Zero Padding problem

Open honamida opened this issue 7 years ago • 5 comments

Hi, There're some operators with zero padding doesn't provide an interface setting the padding and stride. In the tutorial it said we don't need to specify the value since it is provided by ConvPoolOpBase, but the default value of zero padding is 0, which I don't know how to change it. Is there any idea to set the zero padding and stride argument in Python / C++ ? Thanks!

honamida avatar May 09 '17 13:05 honamida

Finally I found that we can set the arguments (pad_t, pad_b, pad_r, pad_l) as the indication of zero padding, which is not mentioned in operator catalogue. Please alarm me if it is incorrect :)

honamida avatar May 10 '17 10:05 honamida

I used "pad" in python

iteal avatar May 19 '17 05:05 iteal

Thanks to @laetitiaoist , I added a parameter pad=1 to brew.conv(), it did achieve the padding goal.

lhCheung1991 avatar Aug 04 '17 01:08 lhCheung1991

@honamida Hi, do you know how to set the arguments (pad_t, pad_b, pad_r, pad_l). I set them like m.Conv('x', 'y', dim_in, dim_out, kernel_size, pad_t=1, pad_b=1) but it didn't work

liuliu66 avatar Jul 31 '18 12:07 liuliu66

Hi @laetitiaoist @lhCheung1991 @honamida ,

were you able to do assymetric padding in the case of pad_t, pad_b, pad_r, pad_l while training on GPU? I could do it but only on CPU. I get the following error training on GPU:

RuntimeError: [enforce fail at pool_op_cudnn.cu:430] legacy_pad_ == LegacyPadding::CAFFE_LEGACY_POOLING. Cudnn pooling only supports even padding on both sides, with the only exception of the caffe legacy pooling case where we try to preserve backward compatibility with Caffe. Error from operator: 
input: "conv5_" input: "pool5_" input: "pool5__grad" output: "conv5__grad" name: "" type: "MaxPoolGradient" arg { name: "kernel" i: 3 } arg { name: "pad_l" i: 1 } arg { name: "pad_b" i: 0 } arg { name: "cudnn_exhaustive_search" i: 0 } arg { name: "stride" i: 2 } arg { name: "pad_r" i: 1 } arg { name: "order" s: "NHWC" } arg { name: "pad_t" i: 1 } device_option { device_type: 1 cuda_gpu_id: 0 } engine: "CUDNN" is_gradient_op: true

CarlosYeverino avatar Dec 04 '18 08:12 CarlosYeverino