You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/07/04 23:19:56 UTC
[GitHub] ThomasDelteil commented on issue #7895: how can i keep the width
and height same after Conv2d layer
ThomasDelteil commented on issue #7895: how can i keep the width and height same after Conv2d layer
URL: https://github.com/apache/incubator-mxnet/issues/7895#issuecomment-402570884
@itisianlee typically `stride` and `dilation` are behavioral parameter that you want to use when you try to achieve specific behavior. `dilation` when you want to enlarge your receptive field. `stride` when you want to decrease your output resolution. `padding` is typically used in order to control the output size.
Let's first check your formula after fixing `stride` `dilation` and `kernel`.
Using your example:
`stride = (1,1)`
`dilation = (1,1)`
`kernel = (4,4)`
```python
out_height = floor((height+2*padding[0]-1*(4-1)-1)/1)+1
out_width = floor((width+2*padding[1]-1*(4-1)-1)/1)+1
out_height = floor((height+2*padding[0]-3-1))+1
out_width = floor((width+2*padding[1]-3-1))+1
out_height = height+2*padding[0]-3
out_width = width+2*padding[1]-3
padding[0] = 3/2
padding[1] = 3/2
```
You get indeed a non-integer value for your padding, and unfortunately Conv2D does not support asymetric padding.
Two solutions come to mind to solve that:
- use `nd.pad()` that supports asymmetric padding followed by a convolution with (0,0) padding.
- over-pad, for example here using `padding=(2,2)` and use the `nd.slice()` operator to slice one column and one row from your output feature maps.
@szha can you please close this issue? Thanks!
@itisianlee if you would like to follow-up, please create an issue on https://discuss.mxnet.io, thanks!
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services