I am following the Pytorch tutorial on https://pytorch.org/tutorials/beginner/blitz/cifar10_tutorial.html#sphx-glr-beginner-blitz-cifar10-tutorial-py 26
Inside the init for Net class, we have the first fully connected layer specified as
self.fc1 = nn.Linear(16 * 5 * 5, 120)
I am confused where the 5*5 comes from.
If we start from the beginning with a CIFAR-10 image, which is 32x32, and we use the equation
width_out = (width_in - kernel_size + 2*padding)/Stride + 1
Since the image is square and the filter is square, the height_out equation is identical.
Applying the first convolution with 5x5 filter on this gives 28x28 because (32 - 5)+1=28.
Applying the 2x2 with Stride = 2 pooling, gives 14x14   because (28-2)/2+1 = 14
Applying the 2nd convolution with 5x5 filter on this gives 10x10 because (14-5)+1 = 10
This is the part where I am getting lost. To go from 10x10 to 5x5, you’d need to applying another 2x2 with stride 2 pooling, but I don’t see another pooling defined in init.
Could someone explain o me what is going on here?