Stride 2 conv tip

I have the stide2 conv defined:

conv = nn.Conv2d(in_channels=256, out_channels=256,kernel_size=3, padding=1,stride=2)

Out:

torch.Size([1, 256, 25, 25])
torch.Size([1, 256, 13, 13])

but I would like to have it like this:

torch.Size([1, 256, 25, 25])
torch.Size([1, 256, 12, 12])

I tried altering the dilation, padding, but didn’t work. How to make conv2d use the floor operation ( ⌊x⌋) for dimensions?

You could play around with other settings, e.g. conv = nn.Conv2d(in_channels=256, out_channels=256,kernel_size=5, padding=1,stride=2) would create the desired output shape. However, if you don’t want to change the kernel_size it might be easier to just slice the output.

I just wanted to confirm I am not missing something since I would keep these 3x3 kernels. The only thing I like better are 1x1 kernels.