3.4.3 · D2Convolutional Neural Networks

Visual walkthrough — Pooling layers (max, average)

1,835 words8 min readBack to topic

This is the visual walkthrough child of the parent pooling note. There we stated the pooling formulas. Here we build them from a single grid of numbers, one picture at a time, never using a symbol before you can see it.

By the end you will be able to draw max pooling, average pooling, the shrinking of the feature map, and even the way gradients flow backwards — all from scratch.


Step 1 — Meet the grid and the window

WHAT. We start with a grid of numbers. "" means 4 rows and 4 columns, so 16 numbers total. On top of it we place a small window — a square that covers exactly 4 cells at a time.

WHY. Before any math, you need to see the two objects the whole operation involves: the big grid (the input) and the little window (the thing that slides). Every later step is "where is the window now, and what number does it produce?"

PICTURE. The cream grid below holds our numbers. The orange square is the window sitting on the top-left corner — its home position.

Figure — Pooling layers (max, average)

Everything past this point is: slide the window, summarise the patch it covers.


Step 2 — One window, one summary number (the max)

WHAT. For the four numbers the window currently covers, we keep only the largest one and throw the other three away. That largest number becomes a single output cell.

WHY. In a CNN a large activation means "this feature is strongly present right here." Keeping the maximum keeps the loudest evidence and discards the quieter background — this is why it is called max pooling.

PICTURE. The window covers . We circle the biggest, , in teal; the arrow carries it out to the first cell of a new, smaller grid.

Figure — Pooling layers (max, average)

Reading the equation term by term:

  • — the output cell we are filling: output row 0, column 0.
  • — the word "max" is a function that answers one question: "which of these is biggest?" We pick it over "sum" or "average" because we want the peak, not the total.
  • each under the brace — one of the four input cells the window is sitting on right now.

Step 3 — Slide the window: stride

WHAT. We move the window to the right by 2 columns, land on the next patch, and take its max. That "2" is called the stride — how far the window jumps each move.

WHY. If we jumped by only 1, consecutive windows would overlap and share cells. Jumping by the full window width () makes the patches tile the grid with no overlap — the clean, most common setup. The stride is the single dial that controls overlap.

PICTURE. The window is now on the top-right patch ; its max, , drops into output cell . Notice the window's left edge moved from column 0 to column .

Figure — Pooling layers (max, average)

Step 4 — Cover every patch: the full max-pool

WHAT. Repeat the slide for the two bottom patches. Four patches → four output numbers → a complete output grid.

WHY. We must show all windows, not just the first, so no patch is left un-summarised. The bottom-left patch gives ; the bottom-right gives .

PICTURE. All four windows and their four teal outputs, assembled into the shrunken grid.

Figure — Pooling layers (max, average)

The grid became . That shrinkage is not luck — it comes from a formula.


Step 5 — Why the output is exactly this small

WHAT. We derive the output height. The window's last valid position is when its right edge just reaches the grid's edge — no hanging off. Count how many jumps fit.

WHY. You need to predict output size for any and , not just guess "half." A window of width must start no later than ; jumps of size between and give the count.

PICTURE. A number line of possible start positions; dots mark the legal window starts, and the count of dots is the output height.

Figure — Pooling layers (max, average)

Step 6 — Change the summary rule: average pooling

WHAT. Same sliding window, same tiling — but instead of "biggest," each patch reports its average: add the four numbers, divide by 4.

WHY. Sometimes you don't want the single loudest cell; you want "how much of this feature is here overall." Averaging keeps every cell's contribution, giving a smoother result. We pick division-by- because there are cells in the window, and an average is total over count.

PICTURE. The top-left patch : all four highlighted in plum (not just one), summed to , divided by .

Figure — Pooling layers (max, average)
  • — add up all cells in the window (not pick one — that is the whole difference from max).
  • — divide by the cell count to turn a sum into a mean.

Full average output:

Compare Step 4's (spiky) with these (gentle). Same window, different personality.


Step 7 — Running the film backwards: gradients

WHAT. During training, an error signal arrives at each output cell and must be pushed back onto the input cells. For max pooling it goes only to the cell that won (was the max); for average it is split equally.

WHY. A gradient measures "if I nudge this input, how much does the loss change?" In max pooling only the winner touched the output, so only the winner can affect the loss — every other cell had zero influence, hence zero gradient. In average pooling every cell contributed , so each gets that same slice back.

PICTURE. Left panel: incoming gradient routed to the single winner cell (value ), zeros elsewhere. Right panel: the same spread as across all four cells.

Figure — Pooling layers (max, average)
  • winner cell keeps the whole incoming gradient — it was the only path.
  • — each of the 4 cells gets an equal quarter, mirroring how each contributed a quarter forward.

This backwards routing (sparse vs dense) is why max pooling trains a few strong detectors while average pooling nudges everyone gently — it also underlies Global Average Pooling and appears in ResNet Architecture and VGG Network.


The one-picture summary

Everything above in a single frame: the grid, the sliding window, the two summary rules diverging, the shrunk outputs, and the gradient flowing back.

Figure — Pooling layers (max, average)
Recall Feynman retelling — say it back in plain words

Start with a grid of numbers where big means "feature is loud here." Lay a tiny square window on the top-left corner. Max pooling keeps only the loudest number in that square; average pooling keeps the square's average instead. Now hop the window across by its stride — hop by the full width and the squares tile perfectly with no overlap. Each hop makes one output number, so a grid collapses to . How small exactly? Count the legal window start-positions: . When we later train the net, the error signal walks backwards — for max it goes only to the cell that won, for average it splits into equal pieces. No weights are ever learned; the window is a fixed rule, and that simplicity is the point.

Recall Quick self-test

Max of the patch ::: Average of ::: Output size for ::: Where does the max-pool gradient go ::: only to the cell that held the maximum Number of learnable parameters in a pooling layer ::: zero

Prerequisites revisited: Convolutional Layers, Feature Maps, Receptive Field, Translation Invariance, Stride and Padding.