Lessons › Chapter 9: Computer vision
Pooling and stride
Split the map into 2 × 2 blocks (one color each).
Watch it move. This lesson is interactive on Gradient Lab: every step is an animated scene you can replay.
Start the interactive lessonStep by step
Photos are huge
Phone photos are millions of pixels. Leo needs to shrink them sensibly as they pass through the network.
A feature map is big
Feature maps can be large, and there are lots of them. Carrying every number through every layer is slow and makes the network fussy about exact positions.
Group into small blocks
Split the map into 2 × 2 blocks (one color each).
Keep the strongest
From each block keep only the biggest number. That’s max pooling. The 4 × 4 map becomes 2 × 2: a quarter of the size, keeping the strongest signals.
Why it helps
If the pattern shifts by one pixel, the biggest value in its block usually stays the same, so the network barely notices small shifts. Fewer numbers also means faster training. Using a bigger step size (stride) when sliding filters shrinks maps in a similar way.
In real life: zooming out on a map
Zoom out on a map app and the side streets disappear while the main roads stay. You keep the strongest features and lose fine detail you don’t need at that scale. Pooling does the same inside a vision network.
Quick check: Max pooling on the block [1, 7, 3, 2] gives…
- 3.25
- 7 (correct)
- 1
Max pooling keeps the largest value in each block.
Pseudocode
feature_map = a 4 × 4 grid
for each 2 × 2 block:
keep only the largest number # max pooling
result = a 2 × 2 map
# smaller, faster, and it barely cares if the pattern shifts a little
Key terms
- pooling
- Shrinking a feature map by keeping one number (often the biggest) from each small block.