The single layer that changed computer vision
A convolutional layer is the fundamental building block of image processing networks. Forget matrix multiplication for a moment — think about sliding a small window across an image.
A filter (kernel) is a small matrix — typically 3×3 or 5×5 — that slides across the input. At each position, it does element-wise multiplication with the local patch and sums the results. Sliding across the entire image produces a 2D feature map. A Conv2D layer with 32 filters applies 32 different filters, producing 32 feature maps stacked.
The key insight: weight sharing. The same 3×3 filter is applied at every position. This gives CNNs translation invariance (a cat detector works whether the cat is top-left or bottom-right) and extreme parameter efficiency. A Conv2D(64, 3) layer on 3-channel input has just (3×3×3 + 1) × 64 = 1,792 parameters — far fewer than a Dense layer touching the same spatial data.
Padding rules: 'same' zero-pads so output spatial size equals input. 'valid' doesn't pad, so output shrinks by kernel_size - 1.