pooling layer
A pooling layer shrinks a feature map by summarizing each small neighbourhood into a single number — like resizing a photo down by replacing every 2x2 block with one representative value. It has no learnable weights; it just applies a fixed rule (take the maximum, take the average) over a sliding window. The point is twofold: make the representation smaller and cheaper for later layers, and make it a little tolerant to exactly where a feature sits, since a feature anywhere within a pooling window lands in the same summarized cell.
Precisely, a pooling layer applies a window of size k with a stride S (typically k = S = 2, giving non-overlapping windows) to each channel independently, producing an output of size floor((W - k)/S) + 1 per spatial axis. Because it operates channel-by-channel, the number of channels is unchanged — only height and width shrink. The two standard reductions are the maximum (max pooling) and the mean (average pooling) over each window; pooling does not mix information across channels and adds no parameters, so it is purely a downsampling and aggregation operation.
Pooling provides local translation invariance: shift a detected feature by a pixel or two and a max-pooled output often does not change, which helps a classifier that cares about 'is the feature present' more than 'is it at column 47'. But this invariance is also a liability for tasks needing precise location, and pooling discards information irreversibly. Consequently many modern networks reduce or remove explicit pooling — ResNet pools once at the stem and once (global average pooling) at the head, downsampling elsewhere with strided convolutions — and vision transformers abandon it for patch embeddings and attention.
2x2 max pooling with stride 2 turns a 32x32x64 feature volume into 16x16x64: each axis halves, channel count (64) is unchanged, and zero parameters are added.
Why it matters / pitfall: pooling buys invariance by destroying detail. For classification that is fine; for segmentation, depth estimation, or super-resolution it is harmful, which is why U-Net-style decoders use skip connections to recover the spatial detail that pooling threw away. Do not pool away resolution you will later need to reconstruct.