Pooling shrinks a feature map by summarizing each little region into a single number. After convolution finds where features fire, pooling throws away spatial resolution you don't need — keeping the signal, dropping the bulk.
Where you meet it
- Classic CNNs — a
conv → ReLU → poolblock, repeated, is the backbone of AlexNet and VGG. - Max pooling after conv layers in almost any vision model.
- Global average pooling at the very end, collapsing a whole map to one value per channel before the classifier.
What it does
It downsamples the spatial dimensions of a feature map while leaving the number of channels untouched. The point isn't to find features — convolution already did that — but to make the representation smaller, cheaper, and a little less fussy about exact position.
Pooling has nothing to learn — it just throws away exact position to keep the signal, which is great until you actually need the position.
How it works
A small window (commonly 2×2) slides over the feature map and reduces each window to one value. With a stride equal to the window size the windows don't overlap, so a 2×2 pool with stride 2 discards 75% of the activations:
- Max pooling takes the strongest activation in the window — "did this feature appear here at all?"
- Average pooling takes the mean — a smoother, softer summary of the region.
import torch.nn as nn
pool = nn.MaxPool2d(kernel_size=2, stride=2)
# input (N, C, 32, 32)
# output (N, C, 16, 16) # H and W halved, C unchanged
Three things fall out of this: less compute for every layer that follows, a larger receptive field (each later neuron now sees more of the original image), and a bit of translation tolerance — nudge the bright pixel within its window and max pooling returns the same number. Crucially, pooling has no learnable parameters: it's a fixed reduction, nothing to train.
Watch out
- It loses location. You learn roughly where a feature is, not exactly — fine for classification, harmful for tasks that need precise positions (segmentation, detection).
- Aggressive pooling discards detail. A bigger window or larger stride shrinks faster but throws away more; pool too hard and fine structure is gone for good.
- Max vs average is task-dependent. Max dominates in vision (it keeps the sharpest evidence); average gives smoother, less peaky summaries and is the standard choice for the global pool before a classifier.
- Modern nets often skip it. Many architectures replace pooling with strided convolutions (a conv that downsamples and learns how) or lean on global average pooling instead of fully-connected heads.
Go deeper
Pooling verkleinert eine Feature Map, indem es jede kleine Region zu einer einzigen Zahl zusammenfasst. Nachdem die Convolution gefunden hat, wo Merkmale feuern, wirft Pooling die räumliche Auflösung weg, die man nicht braucht — das Signal bleibt, die Masse fällt.
Wo es vorkommt
- Klassische CNNs — der wiederholte Block
conv → ReLU → poolist das Rückgrat von AlexNet und VGG. - Max-Pooling nach Conv-Schichten in nahezu jedem Vision-Modell.
- Global Average Pooling ganz am Ende — eine ganze Map wird auf einen Wert pro Kanal kollabiert, bevor der Klassifikator kommt.
Was es tut
Es downsamplet die räumlichen Dimensionen einer Feature Map, lässt die Anzahl der Kanäle aber unangetastet. Es geht nicht ums Finden von Merkmalen — das hat die Convolution schon erledigt — sondern darum, die Repräsentation kleiner, billiger und etwas unempfindlicher gegen die genaue Position zu machen.
Pooling lernt nichts — es wirft die genaue Position weg und behält das Signal, prima, bis du die Position wirklich brauchst.
Wie es funktioniert
Ein kleines Fenster (meist 2×2) gleitet über die Feature Map und reduziert jedes Fenster auf einen Wert. Bei einem Stride gleich der Fenstergröße überlappen die Fenster nicht — ein 2×2-Pool mit Stride 2 verwirft also 75% der Aktivierungen:
- Max-Pooling nimmt die stärkste Aktivierung im Fenster — „ist dieses Merkmal hier überhaupt aufgetaucht?"
- Average-Pooling nimmt den Mittelwert — eine glattere, weichere Zusammenfassung der Region.
import torch.nn as nn
pool = nn.MaxPool2d(kernel_size=2, stride=2)
# Eingabe (N, C, 32, 32)
# Ausgabe (N, C, 16, 16) # H und W halbiert, C unverändert
Daraus folgen drei Dinge: weniger Rechenlast für jede nachfolgende Schicht, ein größeres rezeptives Feld (jedes spätere Neuron sieht nun mehr vom Originalbild) und etwas Translationstoleranz — verschiebt man das helle Pixel innerhalb seines Fensters, liefert Max-Pooling dieselbe Zahl. Entscheidend: Pooling hat keine lernbaren Parameter — es ist eine feste Reduktion, nichts zu trainieren.
Worauf achten
- Es verliert die Ortsinformation. Man erfährt grob, wo ein Merkmal ist, nicht exakt — gut für Klassifikation, schädlich für Aufgaben mit präzisen Positionen (Segmentierung, Detektion).
- Aggressives Pooling verwirft Details. Größeres Fenster oder größerer Stride schrumpft schneller, wirft aber mehr weg; poolt man zu stark, ist feine Struktur endgültig verloren.
- Max vs. Average ist aufgabenabhängig. Max dominiert in der Vision (es behält die schärfste Evidenz); Average liefert glattere, weniger spitze Zusammenfassungen und ist der Standard für den globalen Pool vor dem Klassifikator.
- Moderne Netze sparen es oft aus. Viele Architekturen ersetzen Pooling durch Strided Convolutions (eine Convolution, die downsamplet und lernt, wie) oder setzen auf Global Average Pooling statt voll verbundener Köpfe.