What is you input size? Note that you’ll lose 2 pixels at each conv layer, as your kernel_size=5 and you don’t use any padding.
Also the arguments for nn.AvgPool2d are kernel_size, stride, padding. So currently you use stride=2 and add padding=1.
To easily debug your shape, just add print(x.shape) before the .view op to see the current output shape.