In my case it is not working.
input shape : 1x28x28
nn.Conv2d(in_channels=1, out_channels=32, kernel_size=5, stride=2, dilation=1, padding=0)
Output shape : 32x12x12
According to your equation it should be [28 + 0 - 5 - 0] / 2 + 1= 12.5 which is not possible.
Could you please help.