Thanks for your reply. But a tensor with dimension (1,1,14,14) still get the error of dimension:
RuntimeError: size mismatch, m1: [128 x 4], m2: [512 x 169] at /Users/soumith/code/builder/wheel/pytorch-src/aten/src/TH/generic/THTensorMath.cpp:2070
I don’t know why (1,1,13,13) which I thought should work still give dimension error. I’ve calculated the appropriate padding, kernel size and stride in order not to have these dimensions issues, I’ve used the expression: Out_width = ( in_width - kernel_width + (2*padding) )/1 +1
So what I understand is that:
input dim should be :  (1, 1, 13, 13)
then after cnn1:         (16, 16, 16)     (because kernel=4, padding=3, out_channels=16)
then after maxpool1:  (16, 8, 8)          (because kernel=2)
then after cnn2:        (32, 8, 8)          (because kernel=5, padding=2, out_channels=32)
then after maxpool2:  (32, 4, 4)          (because kernel=2)
then after fc1:            (13*13)
I’m really confused what’s wrong in my reasoning! can anyone please help?