Computer Vision
Pooling (Max & Average)
Shift an input feature and trace how crossing a pooling window changes the output.
Max, window 2×2, stride 2, shift 0. Y[0, 0] = 0.3.
Input to pooling · 6×6
Max pooling window at output position 0 of 8, result is 0.3.
- Nonnegative Value
- Negative Value
- Pooling Window
Edit source values before shift
What is one cell in this grid?
Each cell is one editable scalar. The lab starts with these values directly.
Check this stage
Check your understanding
Inspect max and average pooling on signed windows. Change stride, shift the source, and see exactly which values produce each pooled output.
Pooling replaces each full window with either its largest signed value or its signed arithmetic mean. Move the selected output to see the sampled input coordinates, including tied maxima and zeros supplied by the horizontal shift.
Count full windows
The source is one editable square plane. Rows increase downward and columns to the right, starting at zero. The default input is 6×6, the window 2×2, the stride 2 and the output 3×3. You can change the active input side from 4 to 6, the window side from 2 to 4 and the stride from 1 to 4.
Output row r and column c start at input row r × stride and column c × stride. A window of side k fits on an axis of size n if its start is at most n − k. The starts are 0, stride, twice stride and so on, through that bound. There are floor((n − k)/stride) + 1 starts when a window fits. For n = 5, k = 2 and stride = 2 the starts are 0 and 2. Starting at 4 would require a partial window, so the last input position is unused. Ceiling mode and pooling padding are absent. A stride smaller than k overlaps windows. A stride greater than k leaves gaps.
Compare max and average on one footprint
Keep source, shift, shape, window, stride and valid starts fixed, and switch only the reduction. Max takes the largest signed sample, even if every value is negative. Every sample equal to the maximum appears in the ledger. The scalar reduction saves no argmax and uses no coordinate tie-break. Average adds the signed samples in row-major order and divides by the number of entries, k².
Try the cancellation preset. The four values 1, −1, −1 and 1 give a maximum of 1 at two positions and an exact zero mean. A positive impulse of 1 with three zeros gives max 1 and mean 0.25. A complete constant window preserves its value under either mode. Grid labels round to one decimal and can be omitted in tight cells. Fill uses sign and absolute magnitude relative to the largest magnitude in each map, with an opacity floor and ceiling. Use inspection to distinguish a rounded label from an actual zero. No activation, interpolation or grid colour feeds back into the operation.
Shift the source before pooling
Positive shift moves the source right and negative shift moves it left. The vacated positions are literal zeros in the pooling input. They count in the average divisor and can become maxima when the other samples are negative. The shift comparison subtracts the unshifted raw map with the same source, mode, window, stride and full-window rule.
A maximum can survive a move inside its window if no larger sample enters. At stride 2, moving an impulse from column 1 to column 2 changes which output samples it. Stride-aligned shifts can move corresponding interior outputs by whole output positions, a form of equivariance. The clipped boundary and other sampling phases can change the map. Preserving the map’s largest scalar does not establish position-independent recognition.
Average pooling smooths with a box filter before sampling, whose frequency rejection is limited. Max is a nonlinear local reduction. The lab adds no separate anti-aliasing filter. Strided sampling can therefore still be sensitive to phase. Compare the actual signed differences, rather than the relative brightness of separately normalised maps.
What survives the reduction
A pooled value identifies a region and its summary. It generally cannot identify the input pattern. Frameworks can optionally save a max location for unpooling. That location supports placement of the retained maximum while the other input values remain unknown. Interpolation similarly estimates from the retained grid. This lab shows one scalar plane with no channel or batch axes, global or adaptive modes, derivatives or training.
Each window is a footprint on this plane. The receptive field of a later layer in original-image coordinates depends on the layers composed before and after pooling. This operation has no learned weights, but architecture and training determine the network’s cost, parameter count and task performance.
References
Stage recap
The Feature Map
Each cell is one editable scalar. The lab starts with these values directly.
Max Pooling
Max pooling keeps the largest signed value. Inspect a window to see every tied maximum.
Average Pooling
Switch to Average and inspect the signed sum and divisor on the same window.
Shift and Sampling
Shift by one column and compare against the same source at shift zero. Window membership can change.
Reference
- Max Pooling
- Largest signed value in the window
- Average Pooling
- Signed sum divided by the number of samples
- Stride
- Distance between successive starts along either axis
- Shift sensitivity
- Window membership can change as the source moves
- Downsampling
- Evaluating a spatial operation on a coarser grid
Break it on purpose
Positive and negative samples cancel to an exact zero mean in this nonzero window.
Explore next
- Convolution / CNNChange the filter and trace the dot product that builds each cell of the output feature map.
- Image KernelsEach output cell is the sum of the nine pixel–weight products under its window.
- BackpropagationMultiply local Jacobians along each path; add contributions where a value feeds multiple paths.