I would like to use a convolution for a input image, but the kernel size is defined by [1,2], and I have to make the output feature map same size with the input image. I’m wondering if I can use a padding as (0,0.5)?
Thanks.
I would like to use a convolution for a input image, but the kernel size is defined by [1,2], and I have to make the output feature map same size with the input image. I’m wondering if I can use a padding as (0,0.5)?
Thanks.
No. You can either pad by 1 and later throw away a column or use the separate torch.nn.functional.pad function.
Best regards
Thomas
Thanks.
What do you mean by using the separate torch.nn.pad function? Can you please provide more details?
I fixed the link, sorry.
You can use pad
to match the dimension you want.
nn.Conv2d(...padding=1) # H*W
nn.Conv2d(...padding=2) # (H+2)*(W+2)
If you want (H+1)*(W+1)
in this case, you can produce H*W
and pad by (left=0,right=1,top=0,bottom=1) to get (H+1)*(W+1)
.