Start studying
Module 3 · Computer Vision Module contents
Module 3  ·  Card 6 / 22beginner

Pooling

Pooling shrinks a feature map by summarising small neighbourhoods.

Max pooling keeps the largest value in each window.

Average pooling keeps the mean instead.

It reduces computation and gives slight tolerance to small shifts.

Pooling has no learnable parameters of its own.

Learn in depth ↓
Module 03 · Computer Vision · 22 concepts
In depth  /  15 lines

Pooling, in more detail

Pooling shrinks a feature map by summarising each small neighbourhood into one number.

A 2 by 2 window with a stride of two halves the height and the width.

Max pooling keeps the largest value in the window.

The reasoning is that the strongest response is what matters, not where exactly it was.

Average pooling takes the mean, which is gentler and blurs the signal a little.

Max pooling is far more common in practice.

The saving is real, since a quarter of the values means a quarter of the downstream work.

It also grants a little tolerance to small shifts in the input.

Move an object two pixels and the pooled output is often unchanged.

That is helpful for classification and unhelpful for anything needing exact position.

Pooling has no learnable parameters at all, so it adds nothing to model size.

Global average pooling collapses each channel to a single number at the end of a network.

It replaced the large dense layers old architectures used and cut parameters dramatically.

Some modern designs drop pooling entirely in favour of strided convolution.

Segmentation networks have to undo it later, which is what the upsampling half of a U-Net does.

Want the full technical article? Wikipedia ↗
Deep dive

What is underneath Pooling

Downsampling with no parameters

O(i,j)=max⁡(m,n)∈RijI(m,n)O(i, j) = \max_{(m,n) \in R_{ij}} I(m, n)
  • RijR_{ij}: the window of the input that this output position summarises.

Max pooling takes the largest value in each window and discards the rest. A 2 by 2 window with stride 2 quarters the number of positions.

O(i,j)=1∣Rij∣∑(m,n)∈RijI(m,n)O(i, j) = \frac{1}{|R_{ij}|} \sum_{(m,n) \in R_{ij}} I(m, n)

Average pooling takes the mean instead. Neither has a single weight to learn, which is why pooling layers are invisible in a parameter count and very visible in a memory profile.

O=⌊W−KS⌋+1O = \left\lfloor \frac{W - K}{S} \right\rfloor + 1

The output size follows the same rule as a convolution with no padding, and the usual K=S=2K = S = 2 halves each spatial dimension.

What the gradient does

∂L∂I(m,n)={∂L∂O(i,j)if (m,n)=arg⁡max⁡Rij 0otherwise\frac{\partial \mathcal{L}}{\partial I(m,n)} = \begin{cases} \frac{\partial \mathcal{L}}{\partial O(i,j)} & \text{if } (m,n) = \arg\max R_{ij} \ 0 & \text{otherwise} \end{cases}

Max pooling routes the entire gradient to the one input that won, and gives nothing to the others.

∂L∂I(m,n)=1∣Rij∣∂L∂O(i,j)\frac{\partial \mathcal{L}}{\partial I(m,n)} = \frac{1}{|R_{ij}|} \frac{\partial \mathcal{L}}{\partial O(i,j)}

Average pooling splits it evenly across the window.

So the forward pass needs the values and the backward pass needs the indices of the winners, which is the one thing a pooling layer has to remember.

What it buys

Each pooling layer doubles the reach of everything above it, so a small kernel in a late layer covers a large part of the original image.

positions→14,arithmetic above→14\text{positions} \to \frac{1}{4}, \qquad \text{arithmetic above} \to \frac{1}{4}

It also quarters the work of every layer that follows, which is most of why a deep image network is affordable at all.

Small translations of the input often leave the maximum of a window unchanged, so the representation is slightly invariant to where a feature sits.

What it costs

224→112→56→28→14→7224 \to 112 \to 56 \to 28 \to 14 \to 7

Five halvings take an image to a 7 by 7 grid, and everything finer than 32 pixels of the original has been thrown away.

That is fatal for segmentation and detection, which need to say where something is to the pixel. It is why U-Net keeps skip connections and why detectors read from several depths at once.

Modern architectures increasingly replace pooling with a strided convolution, which downsamples with learned weights instead of a fixed rule, at the cost of parameters and arithmetic.

The one that replaced the flatten

O(c)=1HW∑i=1H∑j=1WI(i,j,c)O(c) = \frac{1}{H W} \sum_{i=1}^{H} \sum_{j=1}^{W} I(i, j, c)

Global average pooling collapses each channel to a single number, turning a feature map into a vector the classifier can read.

The alternative, flattening a 7 by 7 by 512 map into a dense layer, costs 25 million parameters and ties the network to one input size.

Global pooling costs none, accepts any input size, and generalises better, which is why every architecture after 2015 uses it.

Test yourself

One question on this card. Every option explains itself once you pick, right or wrong.

Question 1
What is unusual about a pooling layer compared with a convolution layer?
Computer Vision

22 concepts in this module, then a graded test with every answer explained.

Study this module →
↑↓ move↵ openesc close