Pooling, Stride and Padding
How CNNs shrink feature maps: max pooling, average pooling, stride and padding — with the numbers computed in front of you.
📄 Illustrated notes · every chapter as a picture · printable
Quick quiz
3 questions to check your understanding.
Go deeper
University-level written lectures in The AI Lecture Hall:
Transcript
Introduction. CNNs gradually shrink their feature maps so later layers see a bigger picture with less computation. Pooling, stride and padding control how.
Max pooling. Max pooling slides a two by two window with a stride of two, and keeps only the largest value in each window. Six, five, seven and nine. The four by four map becomes two by two: a quarter of the size, keeping the strongest signals.
Average pooling. Average pooling keeps the mean of each window instead: 3.5, 2, 3.25 and 6.75. It is smoother, and a global version, averaging a whole feature map to one number, is common at the end of modern networks.
Stride and padding. Stride is how far the filter moves each step. A stride of two roughly halves the output. Padding adds a border of zeros so pixels at the edge are not ignored, and same padding keeps the size unchanged.
Output size. The output size is n minus k plus two p, divided by the stride, plus one. For a 32 pixel input, a three by three kernel, padding one and stride one, the output stays 32.
Recap. To recap. Max pooling keeps the strongest value, average pooling the mean. Stride sets the step and padding protects the edges. And one formula predicts the output size.