Slide a window across a feature map, take the max or the average at each position, and watch the output shrink.
Max Pooling & Average Pooling
Pool size:
Worth knowing
Max pooling keeps the strongest activation in each window. If one value is high, it survives. The rest are discarded.
Average pooling takes the mean of the window. It preserves the overall energy but dilutes sharp peaks.
The standard setting is a 2x2 window with stride 2. Each pool layer quarters the spatial area and has zero learnable parameters.
Pooling gives translation invariance: move a feature by one pixel and the same window still captures it. The output does not change.
Overview
What pooling does
A conv layer makes a feature map the same size as its input (when padded). Stack a few layers and the maps stay large, memory stays high, and every later step is costly. Pooling fixes that by summing up small patches into single values.
The idea is simple. Split the feature map into tiles, usually 2x2. Replace each tile with one number. The output is half the width and half the height — one quarter the area. That quarter keeps most of the signal, because nearby pixels in a feature map tend to hold similar info.
Two rules dominate: take the max of the tile, or take the mean. Both shrink the map. They differ in what survives.
Slide a window across a feature map, take the max or the average at each position, and watch the output shrink.
After a convolution extracts features, pooling shrinks the map so the next layer sees more context with less compute.
What pooling does
A conv layer makes a feature map the same size as its input (when padded). Stack a few layers and the maps stay large, memory stays high, and every later step is costly. Pooling fixes that by summing up small patches into single values.
The idea is simple. Split the feature map into tiles, usually 2x2. Replace each tile with one number. The output is half the width and half the height — one quarter the area. That quarter keeps most of the signal, because nearby pixels in a feature map tend to hold similar info.
Two rules dominate: take the max of the tile, or take the mean. Both shrink the map. They differ in what survives.
Max pooling
Max pooling keeps the strongest value in each tile. If one pixel in a 2x2 block fired at 0.9 and the other three were near zero, the output is 0.9. The feature was found somewhere in that patch, and max pooling records that fact.
This makes max pooling tolerant to small shifts. Move a feature one pixel right and the same tile still catches it. The output stays the same. That trait is called shift invariance, and it is one reason pooling layers exist.
Max pooling was the default for years. VGG-16 uses five 2x2 max-pool layers, each halving the map size. LeNet-5, the model that started modern CNNs, also used a form of it.
Average pooling
Average pooling takes the mean of every value in the tile. If the four pixels are 0.9, 0.1, 0.0, and 0.2, the output is 0.3. The strong peak is spread out by its quiet neighbours.
Average pooling keeps the overall energy of the map better than max pooling. When you want a smooth summary rather than a sharp peak, it is the better pick. Global average pooling is the extreme case: one mean per channel across the whole spatial area, used at the end of modern networks in place of flatten-and-dense.
For middle layers, max pooling is more common. Classification networks care more about whether a feature showed up than about its mean strength.
How the window slides
The pooling tile slides across the map just like a conv filter, set by stride. The usual rule is stride equal to pool size. A 2x2 pool with stride 2 hits every pixel once. A 3x3 pool with stride 3 does the same at a coarser scale.
You can set stride smaller than the pool size to get overlap. A 3x3 pool with stride 2 overlaps by one pixel at each step. AlexNet used this (3x3 pool, stride 2). It gave a small gain over plain tiling at the cost of a bigger output.
The output size follows the same formula as strided convolution:
output = floor((input - pool_size) / stride) + 1
A 32x32 map with a 2x2 pool and stride 2 gives 16x16. A 32x32 map with a 3x3 pool and stride 2 gives 15x15.
Why pooling matters
Shrinks the map. Each 2x2 pool quarters the area. Two pools cut it to a sixteenth. That saves the same factor in compute and memory for every later layer.
Adds shift tolerance. Small shifts in the input move features inside a tile but do not change the output. The network does not need to learn the same feature at every pixel offset.
Grows the receptive field. After pooling, each unit in the next conv layer covers a bigger patch of the original image. A 3x3 filter after one 2x2 pool sees 6x6 of the input. After two pools it sees 12x12. Pooling is one of the two ways a network gets a wide enough view to see whole objects (depth is the other).
Has no learned weights. The rule is fixed: take the max or the mean. No weights, no gradients for the pool layer itself. This makes pooling cheap and immune to overfitting.
Where pooling goes wrong
Too much pooling loses detail. One 2x2 pool is fine. Three in a row shrink a 64x64 map to 8x8. Five shrink it to 2x2. At that point the network cannot tell apart objects that differ only by layout. Tasks like segmentation need that detail, which is why U-Net and feature pyramid networks add skip paths to bring back the lost resolution.
Pooling too early throws away structure the early layers have not yet finished finding. The standard order is conv, then activation, then pool.
Wrong stride. If your stride is less than the pool size, you get overlap and a bigger output than you expected. If stride is 1, pooling barely shrinks anything.
Pooling versus strided convolution
Modern designs sometimes swap pooling for a strided conv. A stride of 2 in a conv also halves each side, and the filter weights are learned. The case for it: downsampling is a choice, and a learned choice may beat a fixed rule.
The case against: pooling has zero weights, is fast, and gives built-in shift tolerance. In practice both work. ResNet uses strided convs; EfficientNet mixes both. The gap between the two is smaller than the design around them.
example_01.pyNumPy
import numpy as np
# 6x6 feature map with a bright patch in the top-left
fmap = np.array([
[9, 7, 3, 1, 0, 2],
[8, 6, 4, 0, 1, 1],
[2, 3, 5, 8, 7, 6],
[1, 0, 4, 9, 8, 5],
[0, 1, 2, 3, 6, 7],
[1, 0, 1, 2, 5, 9],
], dtype=float)
def pool2d(x, size, mode):
h, w = x.shape
oh = (h - size) // size + 1
ow = (w - size) // size + 1
out = np.zeros((oh, ow))
for i in range(oh):
for j in range(ow):
patch = x[i*size:(i+1)*size, j*size:(j+1)*size]
out[i, j] = patch.max() if mode == "max" else patch.mean()
return out
print("input 6x6:")
print(fmap.astype(int))
print()
for mode in ("max", "average"):
result = pool2d(fmap, 2, mode)
print("%s pool 2x2 -> %dx%d:" % (mode, result.shape[0], result.shape[1]))
print(np.round(result, 2))
print()
print("max pooling kept the 9 in the top-left;")
print("average pooling blended it down to %.1f." % pool2d(fmap, 2, "average")[0, 0])
Output
Questions people ask about Pooling Layers in CNNs
Is max pooling or average pooling better? Max pooling is more common for intermediate layers because it preserves the strongest activations. Average pooling works better when you want a smooth summary, especially at the end of a network (global average pooling).
Does pooling have any learnable parameters? No. The operation is fixed: take the max or the mean. No weights are trained during pooling.
What pool size should I use? 2x2 with stride 2 is the standard. 3x3 with stride 2 (overlapping) was used in AlexNet and gives marginally better results at higher compute cost. Sizes above 3 are rare.
Can I pool across channels? Standard pooling operates on each channel independently. The spatial dimensions shrink but the channel count stays the same. Channel-wise pooling is a separate idea (channel attention).
Why not just use stride 2 in the convolution instead? You can, and modern networks often do. Strided convolution learns what to keep. Pooling applies a fixed rule. Both downsample. The practical difference is small.
Does pooling help with overfitting? Indirectly. By shrinking the map, pooling reduces the number of values flowing into later layers, which means fewer parameters downstream and less room to memorise training data.
Recall check
0 of 3
Say the answer out loud before you reveal it — recalling it is what makes it stick, and rereading it is not.
What does this module say about “What pooling does”?
What does this module say about “Max pooling”?
What does this module say about “Average pooling”?
Cheat sheet
Pooling Layers in CNNs
Slide a 2x2 or 3x3 window across a feature map, take the max or average at each position, and watch the output shrink.
Ashish Jangra builds and maintains VizLearn. Every module here is written and the visualisation behind it hand-built, so the numbers in a readout come from the same code that draws the picture. Corrections are genuinely welcome and get priority over everything else — if a page states something wrong, or an animation misrepresents what the algorithm does, get in touch.