What is pooling in a CNN?
Pooling is a CNN operation that shrinks a feature map by summarizing each small window of values with one number, usually the maximum (max pooling) or the mean (average pooling). It has no learned weights. A 2×2 pool with stride 2 halves the width and height of every channel and keeps 25% of the values.
Pooling layers appear in classic image classifiers such as LeNet, AlexNet and VGG, where they cut computation and make the network tolerant of small shifts in the input. Modern architectures still use global average pooling to turn the final feature maps into a vector for the classifier, and many have replaced the intermediate pooling layers with strided convolutions.
Key ideas
- Pooling summarizes each window of a feature map with a single number and has no learned weights.
- Max pooling keeps the strongest activation in each window, and average pooling keeps the mean.
- A 2×2 pool with stride 2 halves height and width and keeps 25% of the values.
- The output width is ⌊(W − k)/s⌋ + 1 for input width W, window size k and stride s.
- Global average pooling turns each channel into one number, giving a fixed-length vector for the classifier.
- Strided convolutions can replace pooling with downsampling the network learns.
Common questions
Does pooling make CNNs translation invariant?
Only partly. A feature that moves within one pooling window gives the same max, so small shifts are absorbed, but a shift across a window boundary can change the output. Zhang (2019) showed that standard CNNs are not shift invariant and added a blur before downsampling (anti-aliased pooling) to fix much of the problem.
Does a pooling layer have trainable parameters?
No. Max and average pooling are fixed functions of their input, so they add no weights to the model. Gradients still pass through them during backpropagation, which is why pooling layers sit between trainable convolutional layers without blocking learning.
What is adaptive pooling?
Adaptive pooling takes a target output size instead of a window size and picks the windows to fit. PyTorch's AdaptiveAvgPool2d((1, 1)) is global average pooling for any input size, and AdaptiveAvgPool2d((7, 7)) lets a classifier head accept images of different resolutions.
What is RoI pooling in object detection?
RoI (region of interest) pooling, from Fast R-CNN, crops the feature map to each proposed box and max-pools it into a fixed grid such as 7×7. Every box, whatever its size, then produces a feature vector of the same length for the classification and box-regression heads. Mask R-CNN replaced it with RoIAlign, which avoids rounding the box coordinates.
Related explainers
- Convolutional Neural Networks — How CNNs see and understand images
- Object Detection — Locate and classify multiple objects in an image using bounding boxes and confidence scores
- Image Segmentation — Classify every pixel in an image — from semantic regions to individual object instances
- Skip Connections & ResNets — Residual learning and why deeper networks work
- Feature Extraction — How networks find patterns in raw data
- Data Augmentation — Artificially expand training data with transformed copies to reduce overfitting
References
- Lin, Chen & Yan (2013), "Network In Network"
- Springenberg et al. (2014), "Striving for Simplicity: The All Convolutional Net"
- Zhou et al. (2016), "Learning Deep Features for Discriminative Localization", CVPR
- Zhang (2019), "Making Convolutional Networks Shift-Invariant Again", ICML
- Stanford CS231n, "Convolutional Neural Networks for Visual Recognition" course notes
Last updated