Skip to content
AI360XpertBeta
Core ML

Visual explainer

Pooling Layers

Local windows shrink each feature map; max and mean retain different information, and shifts across window boundaries change the result.

Pooling reduces spatial samples while keeping channel identity.
Pooling reduces spatial samples while keeping channel identity.

Pooling summarizes local regions of a feature map. A feature map is a grid of numerical responses produced by an earlier layer. Pooling operates separately on every channel; it does not mix their meanings. Here one 4 by 4 channel becomes 2 by 2, retaining four values instead of sixteen. The cell pitch is the same in this first drawing, so the drawn area falls to one quarter.

That reduces storage for this output tensor by 75% at fixed channel count and numeric format. It does not guarantee a 75% reduction in total model memory, computation or latency. No learned pooling weights are required.

Select the Maximum

A two-by-two max window keeps the largest value.
A two-by-two max window keeps the largest value.

The outlined bottom-right cell wins: max(1, 3, 2, 4) = 4. The output keeps the response, without retaining the other three values. A large activation can represent a learned feature response, but the operator does not know whether that response is useful signal or noise.

Our synthetic fixture uses no padding, dilation one and floor rounding, following the MaxPool2d definition.

Preserve the Window Order

Four disjoint windows produce four spatially ordered maxima.
Four disjoint windows produce four spatially ordered maxima.

The thicker middle lines divide four non-overlapping windows. The top-left window supplies the top-left output. Output cells are enlarged for reading in this scene; their sizes do not encode response magnitude.

The full input, read row by row, is:

X=[1326245135740283]⟶Y=[4658].X=\begin{bmatrix}1&3&2&6\\2&4&5&1\\3&5&7&4\\0&2&8&3\end{bmatrix} \quad\longrightarrow\quad Y=\begin{bmatrix}4&6\\5&8\end{bmatrix}.

For a window of width k and stride s, with no padding, the output side is ⌊(H−k)/s⌋+1\lfloor(H-k)/s\rfloor+1. Here H = 4, k = 2 and s = 2, so each side becomes 2. Channel count stays fixed.

Mean Versus Peak

Average pooling preserves the mean rather than the peak.
Average pooling preserves the mean rather than the peak.

The four bars show the first window's values on a shared zero baseline, at 48 drawing units per activation unit. The dashed reference reaches the maximum, 4; the solid reference marks the mean, 2.5. The mean is (1 + 3 + 2 + 4) / 4 = 10 / 4.

Average pooling aggregates every member. Max reports an extreme; mean reports a level across the region. Neither is universally the better choice. Padding and whether padded values enter the divisor also matter; this fixture has none.

Stay Inside a Window

A shift within one pooling window can leave its maximum unchanged.
A shift within one pooling window can leave its maximum unchanged.

This controlled comparison switches to a one-dimensional row to isolate the boundary. Two-wide windows at stride two turn [4, 0, 0, 0] and [0, 4, 0, 0] into the same [4, 0]. The peak moves within the outlined first window. This is conditional local tolerance, not a guarantee for every translation.

Average the Whole Channel

Global average pooling collapses a whole channel to one mean.
Global average pooling collapses a whole channel to one mean.

Zoom back to the completed 2 by 2 pooled map. Averaging its entire spatial extent gives (4 + 6 + 5 + 8) / 4 = 5.75. Global average pooling applies this reduction independently to each channel, producing one value per channel for a later head. It removes spatial detail and changes how the head can use features; it does not ensure freedom from overfitting.

A Value Loses Its Address

Equal maxima can hide different feature positions.
Equal maxima can hide different feature positions.

Both patches give 4, although one peak is at the top-left and the other at the bottom-right. There is no unique inverse from that pooled scalar. If exact positions matter, retain a higher-resolution path or other information. Returning maximum indices can preserve the winning address for operations such as unpooling, but cannot restore every discarded value.

Overlap Is a Separate Choice

Stride one produces overlapping pooling windows.
Stride one produces overlapping pooling windows.

The brackets select adjacent pairs [1, 3], [3, 2] and [2, 6], whose maxima are 3, 3 and 6. Shared endpoints refer to the same input slots. Window width two does not force stride two.

For the full 4 by 4 fixture, two-dimensional stride-one pooling yields rows [4, 5, 6], [5, 7, 7] and [5, 8, 8]. Its output is 3 by 3. Overlap retains more spatial samples, at the cost of a larger output.

Follow the Backward Signal

Max pooling routes a gradient through the selected maximum.
Max pooling routes a gradient through the selected maximum.

The numbers are now gradients, not activations. Send an upstream gradient of 8 through the first window from beat two. Its unique maximum was the bottom-right 4, so that input receives 8 and the other three receive 0. In contrast, averaging the same four inputs sends 8 / 4 = 2 to each. Tied maxima need an implementation's selection convention; this example avoids ties. With overlapping windows, contributions reaching the same input add.

Where It Breaks

Crossing a window boundary changes the pooled representation.
Crossing a window boundary changes the pooled representation.

Continue the row example: [0, 4, 0, 0] becomes [0, 0, 4, 0] after a one-cell shift. The peak crosses the dashed boundary, so the pooled vector changes from [4, 0] to [0, 4]. A downstream model can distinguish those vectors. Pooling alone therefore does not establish translation invariance, even for a tiny shift.

Use downsampling when its reduction is worth losing spatial samples. Tasks needing exact boundaries benefit from preserving spatial information; choosing max instead of mean cannot recover an address already discarded.

The Quick Version

  • Pooling reduces spatial samples independently in each channel.
  • Max keeps the largest value without learning window weights.
  • Stride two maps four disjoint windows to four ordered outputs.
  • Average keeps a mean rather than an extreme.
  • Some within-window shifts preserve a maximum.
  • Global averaging produces one value per channel.
  • Equal maxima can hide different feature positions.
  • Stride one creates overlapping windows and larger outputs.
  • A unique maximum receives the backward gradient.
  • Crossing a window boundary can change the pooled vector.