Pooling, window by window


Image
What gets pooled
Pooling
Window (= stride)
Shift the picture
Slide the window
one window of the input
→
keep the biggest

The whole idea.
Cut the map into tiles — here 2×2, 3×3 or 4×4 — and replace each tile with a single number. Max pooling keeps the biggest number in the tile; average pooling keeps the mean. The window then jumps a whole tile to the right (the stride equals the window), so no number is looked at twice. A 2×2 window keeps one number out of every four.

Unlike a filter, pooling has no weights. There is nothing to learn and nothing to tune except the window size — it is a fixed rule.

Where it sits in a CNN.
The usual order is filter → ReLU → pool, and then the same again. Pooling does two jobs. It shrinks the map, so the next layer has fewer numbers to work through. And it means every pixel of the next layer stands for a bigger patch of the original picture, so a 3×3 filter two layers down is really looking at a much larger area. Max pooling also asks a simpler question than “exactly where is this edge?” — it asks “is there an edge somewhere in this tile?”

Things worth trying:
1. Cat, Outline + ReLU, Whole map, and flip between Max and Average. The whiskers are only a pixel or two wide, so they fill part of each tile. Max keeps them at full brightness, 255; average blends them with the dark around them, and the brightest whisker tile drops to about half that.

2. Stay on Max, 2×2, and press Pool again after each sweep. The map goes 118×88 → 59×44 → 29×22 → 14×11 → 7×5. Somewhere along the way it stops looking like a cat, but you can still see where the edges were — and once the tiles are big enough, every number is printed on them.

3. House, Vertical edges + ReLU, Max, 2×2, then shift the picture by 1 pixel. Pooling is often said to make a network ignore small shifts, so check: the status line counts what changed. About 5% of the input numbers change — and about 5% of the pooled ones too. One round of pooling buys very little; Average does worse, at 8%. Whatever shift tolerance a real CNN has, it does not come from a single pooling layer.

4. Pick a 3×3 or 4×4 window on a map whose width does not divide evenly. The leftover columns on the right do not fill a whole window, and they are simply dropped.