Ravindra BagaleCourses & study guides मराठी Track your progress

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

  1. Create a fake map.
  2. Apply MaxPool2d(2).
  3. 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)