Part X — Computer Vision: CNNs, ResNets, Object Detection & Segmentation · Chapter 2

Pooling & spatial downsampling

Hook

Convolution kept the image's spatial size almost intact — a 6×6 image gave a 4×4 feature map. Stack a few more filter layers on top of that and the numbers pile up fast. Something has to shrink.

Intuition
22002600004000006004
output (0, 0) — max = 6

This feature map has two detections: a strong one (6) in the top-left window, a weaker one (4) in the bottom-right. Toggle between max and average pooling. Max pooling reports the 6 exactly — it just asks "was this feature detected anywhere in the window?" Average pooling reports 3 — it blends the strong detection with the zeros around it, and the signal gets weaker just from being averaged.

Formalize

Pooling slides a window across a feature map like convolution does, but instead of a learned dot product it applies a fixed reduction — usually the max or the mean — to every value in the window:

maxpool(r,c)=maxi,j feature(rs+i, cs+j)\text{maxpool}(r,c) = \max_{i,j} \ \text{feature}(r{\cdot}s+i,\ c{\cdot}s+j)
  • maxpool(r,c)\text{maxpool}(r,c) — the pooled output value at row rr, column cc.
  • feature()\text{feature}(\cdot) — the input feature map produced by the convolution layer.
  • ss — the stride: how many positions the window shifts between neighboring windows.
  • r,cr, c — the row and column of the output (pooled) position.
  • i,ji, j — the row and column offsets ranging over the pooling window.
  1. Shrinks the map by the stride

    A 2×22\times2 window with stride 22 turns this 4×44\times4 feature map into a 2×22\times2 one — a quarter of the values.

  2. But keeps what matters

    Those values are chosen so nothing important gets thrown away: taking the max of each window keeps the strongest response, not an arbitrary one.

Play
22002600004000006004
output (0, 0) — max = 6

Move the window to the bottom-right corner. Max pooling reports 44 — the one real detection there survives untouched. Average pooling reports 11 — a quarter of 44, diluted by three zeros. Now check the other two windows: both poolings agree on 00, because there's nothing there to lose in the first place. The disagreement only shows up exactly where there's a strong, localized signal — which is exactly why max pooling is the default choice after a convolution layer.

Worked example
  1. Top-left window

    Rows 0-1 and columns 0-1 hold the values 2,2,2,62, 2, 2, 6.

    • Max pooling takes max(2,2,2,6)=6\max(2,2,2,6) = 6 — the exact strength of the strongest detection, unchanged.
    • Average pooling takes 2+2+2+64=3\frac{2+2+2+6}{4} = 3 — half of the true peak, because it's been averaged against three much smaller values.
  2. Bottom-right window

    The values 4,0,0,04, 0, 0, 0 tell the same story at a smaller scale:

    • Max reports 44
    • Average reports 44=1\frac{4}{4}=1
Checkpoint

Choose a window and a pooling mode that reveals the feature map’s strongest detection, 6, exactly.

22002600004000003001
output (1, 1) — average = 1
Move a control to try it
Summary
maxpool(r,c)=maxi,j feature(rs+i, cs+j)\text{maxpool}(r,c) = \max_{i,j} \ \text{feature}(r{\cdot}s+i,\ c{\cdot}s+j)

Pooling shrinks a feature map by a fixed, un-learned rule, trading spatial precision (exactly where in the window something was) for a smaller, more manageable representation — while max pooling keeps the actual strength of whatever was detected. The next chapter puts a filter layer and a pooling layer together, back to back, into the first real convolutional network.