Why cant I change the padding, and strides in Conv2d?
Hi, perhaps I am missing something, but I cannot seem to figure out how to change the padding and stride amounts in the Conv2d method. Thanks
Kalamaya
You can pass them as arguments to the Module constructor e.g. <SCODE>nn.Conv2d(16, 32, kernel_size=3, padding=(5, 3))
<ECODE> Alternatively, if you need to change them at runtime, I’d suggest using the functional interface: <SCODE>import torch.nn.functonal as F

...

F.conv2d(input, self.weight, self.bias, kernel_size=3, padding=(x, y))
<ECODE>
apaszke
The change at run-time is intriguing … I didn’t even know people did that. How could you guarantee the same dimensionality if you changed padding amounts during run time though?
Kalamaya
I don’t know if people do that, but it might be reasonable if you have variably sized inputs, or are doing something completely new.
apaszke
Very interesting - I mean I know that in the context of RNNs we can have variable length inputs etc, since the back-prop can be unrolled N times, but I didnt realize that we could have variable length weights/parameters etc… I’ll read more about it, (and any sources on this are appreciated), but the top question in my mind is how do you guarantee that in a dynamic graph, when we change the dimensionality of weights, that those are new weights are even trained? Does that make sense?
Kalamaya
For example conv layers can be applied to variably sized inputs, with a fixed set of weights.
apaszke
Thank you will take a look!
Kalamaya