47. Convolutional Neural Networks (CNNs) for Images
47.3 Pooling Simply
Why. Feature maps can stay large. Pooling shrinks them and keeps the strong responses.
What. Max-pool (e.g. 2×2) takes the maximum in each window — a simple “what stood out here?” summariser.
How.
See a size drop
- Create a fake map.
- Apply MaxPool2d(2).
- Confirm H and W roughly halve.
import torch
import torch.nn as nn
pool = nn.MaxPool2d(2)
x = torch.randn(1, 4, 28, 28)
print(pool(x).shape) # (1, 4, 14, 14)