Ch 5 ▸ Pooling ▸ Module 1/4
Max pooling.
🔒 This module is locked
It builds on Putting it together. Pass that module’s knowledge check to unlock it, or skip ahead if you already know the material.
Pooling slides a window across a map and replaces each window with a single number, computed by a fixed rule. The window moves exactly like a kernel, with a size and a stride, but it holds no weights. Nothing is multiplied and nothing is learned.
Max pooling is pooling where the rule is “keep the largest value”. The usual setting is a 2×2 window at stride 2. At that stride the windows sit side by side without overlapping, so every pixel lands in exactly one window. Here is a 4×4 map pooled that way, with each window’s largest value picked out:
The top-left window holds 1, 3, 4 and 6, so its output is 6. The top-right holds 2, 0, 1 and 1, so its output is 2, and so on. The output is half as wide and half as tall.
Which input wins
In each window exactly one pixel decides the output. The solid square in figure 5.1a is that pixel, and the listing highlights its value in the patch. The other pixels in the window have no effect at all: lower any of them and the output stays the same.
The brightest pixel in each window always wins, so light areas spread and thin dark lines disappear. In figure 5.1 the duck’s eye is a single black pixel, and the 2×2 window that holds it also holds lighter feathers. The pooled duck has no eye. Inside a CNN, a large value in a map usually means “the pattern this kernel looks for is here”. Max pooling keeps the strongest of those signals from each window and drops the exact pixel it came from.
Output size
Counting outputs works exactly as in chapter 3’s Stride module. On a 16-pixel row with a 2-pixel window, the last start is 16 − 2 = 14. At stride 2 the starts are 0, 2, …, 14, which is 8 outputs, so a 16×16 map pools to 8×8.
Set the window to 3 and leave the stride at 2. The windows now overlap by one pixel, so some pixels can win in two neighboring windows. This is called overlapping pooling: the window is bigger than the stride, so neighboring windows share pixels. AlexNet used 3×3 windows at stride 2. The last start on the 16-pixel row is 16 − 3 = 13, so starts run 0, 2, …, 12 for 7 outputs, and pixel 15 is never read. That’s the same rounding as stride 3 in chapter 3.
Knowledge check ▸ 5 questions
Before you move on.
Answer every question correctly to unlock the next module. A wrong answer gets a hint, and you can try again as many times as you like.
1What does max pooling output for each window?
2A 4×4 map has rows [1, 0, 4, 2], [3, 2, 0, 1], [0, 0, 1, 1] and [6, 0, 2, 9]. After 2×2 max pooling at stride 2, what is the top-right output?
3A 32×32 map goes through 2×2 max pooling at stride 2. How many pixels wide is the output?
4A 13×13 map goes through 3×3 max pooling at stride 2, with no padding. How many pixels wide is the output?
5How many weights does a 2×2 max pooling layer have?