Convolutions, receptive fields, stride and pooling
What it is
A convolution applies the same small learned filter at every image location, producing a feature map whose values say where a pattern is present. The filter's shared weights mean that an edge detector learned in the upper-left can also detect the same edge in the lower-right. Stacking convolutional layers expands each unit's receptive field: early layers see edges and textures, while later layers combine them into larger structures. Stride or pooling reduces spatial resolution, lowering cost and increasing the semantic scale represented by later features.
Why it matters
Weight sharing gives CNNs translation-aware image features with far fewer parameters than a dense layer over pixels. The architecture's locality assumption is useful when nearby pixels are related, but it is not a guarantee of invariance — cropping, augmentation, and data diversity still determine which shifts and distortions the model handles well.
In the real world: The core of image products: spotting defects on a production line, reading number plates, tagging photos.
Visual example
Interactive receptive fieldSelect an output cell to reveal its exact input patch, filter multiplication, and sum.
Why this matters
The same vertical-edge filter is evaluated at every location. Selecting locations makes weight sharing and local receptive fields concrete rather than just naming them.
Common misconception
Wrong idea: a convolution sees the whole image at once.
Correct idea: one convolution output cell sees a small local patch. Depth, stride, and pooling enlarge what later cells can see.
import torch.nn as nn
# (batch, 3, height, width) -> (batch, 64, height/2, width/2)
block = nn.Conv2d(3, 64, kernel_size=3, stride=2, padding=1)Guessing image shapes after every convolution. Track the output formula or inspect tensors; an off-by-one spatial dimension often only surfaces at the final dense layer.