Convolutional networks¶
A convolutional network is an MLP that has been told two facts about images: nearby pixels matter together, and a pattern means the same thing wherever it appears. Building those facts into the architecture — local connections and shared weights — cut the parameter count by orders of magnitude and started the deep-learning era.
10,000 ft
Convolutional neural networks (CNNs) were deep learning's first decisive win. LeNet read cheques in the 1990s; AlexNet's 2012 ImageNet result (15.3% top-5 error against 26.2% for the runner-up) convinced the field to switch to neural networks; ResNet in 2015 made networks hundreds of layers deep. CNNs are the canonical example of an inductive bias: an assumption about the world, wired into the architecture, that makes learning feasible with far less data. Their ideas never went away. Vision transformers (ViT and CLIP) start by cutting an image into patches with what is literally a strided convolution; diffusion models (diffusion) mostly denoise with convolutional U-Nets or transformers that borrowed their tricks; audio models use 1-D convolutions; and residual connections (residual networks) were invented for CNNs before every transformer adopted them.
2,000 ft
A CNN is a stack of convolution layers. Each layer slides a set of small learned filters (say 3×3) over its input; each filter computes a dot product with every local window, producing one feature map per filter. A nonlinearity follows. Every few layers the spatial resolution is halved (stride or pooling) while the number of channels grows, so deeper layers see larger regions and represent more abstract features: edges, then textures, then parts, then objects. At the end, global average pooling collapses the spatial grid and a linear layer classifies.
(Shapes are ResNet-50's.)
Ground level¶
Why not just use an MLP?¶
A 224×224 colour image has \(224\times224\times3 = 150{,}528\) input values. A fully connected layer from that to even 4,096 hidden units needs \(150{,}528\times4{,}096 \approx 617\) million weights — for the first layer alone, before learning anything. Worse, the MLP has to learn separately that a cat's ear in the top-left corner and one in the bottom-right are the same thing: nothing in its structure relates the weights for those two positions.
Images have structure an MLP ignores:
- Locality. A pixel is strongly related to its neighbours and weakly related to pixels far away. Useful low-level features (edges, corners, spots) are local.
- Translation symmetry. The statistics of images are roughly the same everywhere; an edge detector useful in one place is useful in every place.
- Hierarchy. Objects are made of parts, parts of textures, textures of edges.
A convolution layer encodes the first two exactly: each output depends only on a small window (local connectivity), and the same filter is used at every position (weight sharing). Stacking layers encodes the third.
The convolution operation¶
Take a single-channel input \(X\) (height \(H\), width \(W\)) and a \(K\times K\) kernel \(w\). The output at position \((i,j)\) is the dot product of the kernel with the window whose top-left corner is \((i,j)\):
(Mathematicians would call this cross-correlation; true convolution flips the kernel. Since the kernel is learned, the flip is irrelevant, and every deep-learning library computes the unflipped version while calling it convolution.)
With real images the input has \(C_\text{in}\) channels (3 for RGB, 64 or 512 deeper in) and a layer has \(C_\text{out}\) filters, each spanning all input channels. The weight tensor is \(C_\text{out}\times C_\text{in}\times K\times K\) and
where \(s\) is the stride. Every filter produces one output channel — one feature map, a picture of where that filter's pattern occurs.
Output shapes: padding and stride¶
Without padding, a \(K\times K\) kernel can only be placed at \(H-K+1\) vertical positions. With padding \(P\) on each side and stride \(S\):
- \(K = 3,\ P = 1,\ S = 1\) keeps the size ("same" padding): \((224+2-3)/1+1 = 224\).
- \(K = 3,\ P = 1,\ S = 2\) halves it: \(\lfloor 223/2\rfloor + 1 = 112\).
- ResNet's stem, \(K = 7,\ P = 3,\ S = 2\): \(\lfloor 229/2\rfloor+1 = 112\).
Parameters and compute¶
A layer has \(C_\text{out}C_\text{in}K^2 + C_\text{out}\) parameters, independent of the image size. Its cost is one multiply–accumulate (MAC) per weight per output position: \(\text{MACs} = H_\text{out}W_\text{out}\,C_\text{out}C_\text{in}K^2\) (FLOPs ≈ 2 × MACs).
Worked example: ResNet-50's first layer
\(7\times7\) kernels, 3 → 64 channels, stride 2 on a \(224\times224\) image:
- Parameters: \(64\times3\times7\times7 = 9{,}408\) (plus 64 biases, which ResNet omits because BatchNorm follows).
- Output: \(64\times112\times112\).
- Compute: \(112\times112\times9{,}408 \approx 118\) million MACs.
- A dense layer with the same input and output sizes would need \(150{,}528\times802{,}816 \approx 1.2\times10^{11}\) weights.
Weight sharing and locality buy a factor of about ten million. Notice also that the conv layer is compute-heavy relative to its parameters: each weight is used 12,544 times per image. That high arithmetic intensity is why CNNs run so well on GPUs (roofline).
Pooling, stride and the receptive field¶
The receptive field of a unit is the region of the input that can influence it. One 3×3 layer sees 3×3 pixels; two stacked see 5×5; three see 7×7. Downsampling multiplies the growth: after a stride-2 layer every subsequent 3×3 kernel spans twice as many input pixels. The recursion is \(r_\ell = r_{\ell-1} + (K_\ell - 1)\,j_{\ell-1}\), where \(j\) is the product of all strides so far.
Worked example: receptive field of a small stack
conv3 → conv3 → 2×2 max-pool (stride 2) → conv3 → conv3: \(r = 1 \to 3 \to 5 \to 6 \to 10 \to 14\) (the jump \(j\) becomes 2 after the pool, so each later 3×3 adds \(2\times2 = 4\)). Fourteen pixels of context after four convolutions.
Max pooling (take the maximum in each 2×2 window) and strided convolution both halve the resolution; modern networks mostly use strided convolutions and keep one pooling layer at the end: global average pooling, which averages each final feature map to one number, making the classifier independent of image size and removing the huge fully connected layers AlexNet and VGG carried.
Two refinements matter in practice. Luo et al. (2017) showed the effective receptive field is much smaller than the theoretical one — influence falls off like a Gaussian from the centre — so deep stacks or dilated convolutions are needed for real long-range context. And strided downsampling breaks exact translation behaviour: shifting an input by one pixel can change a classifier's output noticeably. Zhang (2019) fixed much of this with anti-aliasing (blur before subsampling), which also improved accuracy.
Equivariance and invariance¶
A convolution is translation-equivariant: shift the input, and the feature maps shift by the same amount (\(\operatorname{conv}(\text{shift}(X)) = \text{shift}(\operatorname{conv}(X))\), up to borders). This is the precise sense in which a CNN "knows" that a pattern means the same thing everywhere. Classification needs invariance — the label should not move at all — and pooling, especially the final global average pool, converts equivariant features into an approximately invariant decision. Convolutions are not built to be equivariant to rotation or scale; those must be learned from data (and are, partly, with augmentation — see regularisation).
Variations on the convolution¶
- 1×1 convolution (Lin, Chen and Yan, Network in Network, 2013): a per-pixel linear map across channels. It mixes channels and changes their number cheaply; GoogLeNet and ResNet's bottleneck blocks use it to squeeze 256 channels to 64 before an expensive 3×3 and expand them again after.
- Depthwise-separable convolution (MobileNet, 2017): a 3×3 filter per channel (depthwise), then a 1×1 to mix channels (pointwise). Its cost relative to a full convolution is \(1/C_\text{out} + 1/K^2\); for 3×3 kernels that is 8–9× fewer operations, which is why phones run MobileNets.
- Dilated (atrous) convolution (Yu and Koltun, 2015): spread the kernel's taps apart with gaps, so a 3×3 kernel covers a 5×5 or 9×9 area. The receptive field grows exponentially with depth without losing resolution — used in segmentation and in WaveNet's audio model.
- Transposed convolution: the gradient of a strided convolution, used as a learnable upsampler in decoders (U-Net, GAN generators). It can produce checkerboard artefacts; resize then convolve is a common alternative. Dumoulin and Visin's guide to convolution arithmetic has the canonical animations of all of these.
- 1-D and causal convolutions for sequences: slide along time only. A causal convolution only sees the past, so it can be used for generation (WaveNet; also the short convolutions inside Mamba-style state-space models).
- Grouped convolution (AlexNet, by necessity across two GPUs; ResNeXt, by design): split channels into groups convolved independently.
What the filters learn¶
Zeiler and Fergus (2013) projected activations back to pixel space and showed the hierarchy that had been hypothesised: first-layer filters are oriented edges and colour blobs (strikingly like the simple cells Hubel and Wiesel recorded in cat visual cortex in 1962), the next layers respond to corners and textures, then to repeated motifs and object parts (eyes, wheels), and the last layers to whole objects and scenes. Olah, Mordvintsev and Schubert's Distill article Feature Visualization (2017) generates images that maximally excite individual units — the most vivid way to see a CNN's internal vocabulary, and a direct ancestor of today's interpretability research.
History¶
How the idea was found
Hubel and Wiesel's recordings (1959–1962) showed neurons in the visual cortex with small receptive fields, some responding to oriented edges and others pooling over positions. Fukushima's Neocognitron (1980) turned that into a layered model of alternating feature extraction and pooling, but trained it without gradient descent. Yann LeCun and colleagues at Bell Labs combined weight-shared convolutions with backpropagation in 1989 to read handwritten zip codes; LeNet-5 (LeCun, Bottou, Bengio and Haffner, 1998) was deployed commercially to read bank cheques. Then CNNs went quiet for a decade, outperformed on most benchmarks by SVMs on hand-engineered features. In 2012 Krizhevsky, Sutskever and Hinton trained a much larger CNN on 1.2 million ImageNet images with two consumer GPUs, ReLUs, dropout and heavy augmentation, and won ILSVRC with 15.3% top-5 error against 26.2%. Within two years nearly every entry was a CNN.
The decade that followed was a sequence of lessons, each still in use:
| Model | Year | Depth | Key lesson |
|---|---|---|---|
| AlexNet | 2012 | 8 | Scale (data, GPUs) + ReLU + dropout makes CNNs win |
| VGG | 2014 | 16–19 | Stacks of 3×3 convs beat larger kernels (three 3×3 = 27C² weights vs 49C² for one 7×7, with more nonlinearity) |
| GoogLeNet | 2014 | 22 | Parallel multi-scale branches and 1×1 bottlenecks; 12× fewer parameters than AlexNet |
| ResNet | 2015 | 50–152 | Identity shortcuts let depth keep helping; 3.57% top-5 error (ensemble), ILSVRC 2015 winner |
| MobileNet | 2017 | — | Depthwise-separable convolutions for phones |
| EfficientNet | 2019 | — | Scale depth, width and resolution together; B7 reached 84.3% top-1 while 8.4× smaller than the previous best ConvNet |
| ConvNeXt | 2022 | — | A pure CNN with transformer-era training and design (large kernels, LayerNorm, GELU, inverted bottlenecks) matches Swin transformers; 87.8% top-1 |
As of 2026, transformers dominate large-scale vision pre-training (ViT, CLIP-style encoders inside vision-language models), while CNNs remain the default where compute, latency or small data matter — on-device vision, many industrial and medical pipelines, and as components (patch embeddings, U-Nets, audio front-ends) inside larger systems.
First principles¶
Why does weight sharing work, and what would break without it?
Start from the requirement: a feature detector should respond to its pattern regardless of where the pattern is. Suppose a layer is linear, \(\mathbf y = A\mathbf x\), and must commute with translation \(T\): \(A\,T\mathbf x = T A\mathbf x\) for every image. A linear map that commutes with all shifts must have the same row at every position, shifted — the weight connecting input \(q\) to output \(p\) can depend only on \(q - p\). That is the definition of a convolution. Convolution is not one design among many; it is the only linear layer that is translation-equivariant. Locality is a second, separate assumption (the kernel is zero beyond \(K\)), justified by the statistics of natural images.
The same reasoning generalises. Demand equivariance to rotations as well and you get group-equivariant CNNs; to permutations of set elements and you get DeepSets/graph networks; drop the locality assumption and let the interaction depend on content rather than relative position, and you are close to attention. Choosing an architecture is choosing which symmetries to assume.
What it buys, quantitatively: our worked example cut \(1.2\times10^{11}\) dense weights to \(9{,}408\). Fewer parameters means each one is estimated from many more data points (every image position is a training example for the filter), which is why CNNs learn from tens of thousands of images where an MLP would need vastly more. What it costs: assumptions can be wrong. When the right answer depends on absolute position or on long-range relationships, a pure CNN must work hard (deep stacks, dilation, coordinate channels) to recover what an architecture with weaker biases learns from enough data — the trade that let ViTs overtake CNNs once datasets reached hundreds of millions of images.
The maths¶
Shapes. Input \(X \in \mathbb R^{N\times C_\text{in}\times H\times W}\) (batch, channels, height, width — PyTorch's NCHW order); weights \(w \in \mathbb R^{C_\text{out}\times C_\text{in}\times K\times K}\); bias \(\mathbf b\in\mathbb R^{C_\text{out}}\); output \(Y\in\mathbb R^{N\times C_\text{out}\times H_\text{out}\times W_\text{out}}\).
with \(X\) taken as zero outside its bounds (zero padding).
Convolution as a matrix multiply (im2col). Gather every \(C_\text{in}K^2\)-sized patch into a row of a matrix \(\mathcal X \in \mathbb R^{(H_\text{out}W_\text{out})\times(C_\text{in}K^2)}\); reshape \(w\) to \(\mathcal W\in\mathbb R^{C_\text{out}\times C_\text{in}K^2}\). Then \(Y = \mathcal X\mathcal W^\top\), one GEMM. The im2col matrix duplicates each pixel up to \(K^2\) times, so libraries such as cuDNN choose among implicit GEMM, FFT and Winograd algorithms instead, but the maths is the same.
Derivation: the backward pass of a convolution is two more convolutions
Let \(G = \partial L/\partial Y\) (same shape as \(Y\)). Take stride 1, no padding, one channel, \(Y_{i,j} = \sum_{u,v} w_{u,v}X_{i+u,j+v}\).
Weight gradient. Each \(w_{u,v}\) appears in every output:
which is the cross-correlation of the input with the output gradient: a "convolution" whose kernel is \(G\). Summing over all positions is weight sharing's signature — every position contributes evidence to the same weight.
Input gradient. Pixel \(X_{p,q}\) is touched by every output \((i,j)\) with \(i = p-u\), \(j = q-v\):
a true (flipped-kernel) convolution of \(G\), zero-padded by \(K-1\), with \(w\). Equivalently: a cross-correlation of the padded \(G\) with \(w\) rotated by 180°. With multiple channels, the input-channel and output-channel axes of \(w\) swap roles. The code below checks this numerically to \(3\times10^{-8}\). A strided convolution's input gradient is a transposed convolution — the origin of that layer's name.
Receptive field. With kernel sizes \(K_\ell\) and strides \(S_\ell\), jump \(j_0 = 1\), \(j_\ell = j_{\ell-1}S_\ell\), and \(r_\ell = r_{\ell-1}+(K_\ell-1)j_{\ell-1}\), \(r_0 = 1\).
Depthwise-separable cost. A full conv costs \(H W C_\text{in}C_\text{out}K^2\) MACs. Depthwise (\(K^2\) per channel) plus pointwise (\(C_\text{in}C_\text{out}\) per position) costs \(HW C_\text{in}(K^2+C_\text{out})\). The ratio is \(\frac{1}{C_\text{out}}+\frac{1}{K^2}\).
Build it¶
NumPy: a convolution via im2col, applied to an edge-detection example, the cost of ResNet-50's stem, and a numerical check that the input gradient is a convolution with the flipped kernel.
import numpy as np
def conv2d(x, w, b, stride=1, pad=0):
"""x: (C_in, H, W) w: (C_out, C_in, K, K) b: (C_out,) -> (C_out, H_out, W_out). Cross-correlation, like every DL library."""
x = np.pad(x, ((0, 0), (pad, pad), (pad, pad)))
C_out, C_in, K, _ = w.shape
H_out = (x.shape[1] - K) // stride + 1
W_out = (x.shape[2] - K) // stride + 1
# im2col: gather every K x K x C_in patch into a row, then one matrix multiply does all the work
cols = np.empty((H_out * W_out, C_in * K * K))
for i in range(H_out):
for j in range(W_out):
patch = x[:, i*stride:i*stride+K, j*stride:j*stride+K]
cols[i * W_out + j] = patch.ravel()
out = cols @ w.reshape(C_out, -1).T + b # (H_out*W_out, C_out)
return out.T.reshape(C_out, H_out, W_out)
# A 5x5 image: dark left half, bright right half -> a vertical edge
img = np.array([[0, 0, 0, 9, 9]] * 5, dtype=float)[None] # (1, 5, 5)
sobel_x = np.array([[-1, 0, 1], [-2, 0, 2], [-1, 0, 1]], float)[None, None]
print("edge map:\n", conv2d(img, sobel_x, np.zeros(1)).squeeze())
# Shapes and costs of a real layer: ResNet-50's stem, 7x7 conv, stride 2, pad 3, 3 -> 64 channels
x = np.random.default_rng(0).normal(size=(3, 224, 224))
w = np.random.default_rng(1).normal(size=(64, 3, 7, 7)) * 0.05
y = conv2d(x, w, np.zeros(64), stride=2, pad=3)
params = w.size
macs = y.shape[1] * y.shape[2] * w.size # one MAC per weight per output position
print("stem output", y.shape, "params", params, "MACs", f"{macs/1e6:.1f}M")
# The same mapping as a dense layer would need:
print("dense equivalent weights:", f"{(3*224*224) * (64*112*112):.2e}")
# Gradient check: dL/dx of a conv is a 'full' convolution of dL/dy with the flipped kernel
g = np.random.default_rng(2).normal(size=(1, 3, 3)) # upstream gradient for the 3x3 edge map
eps, x0 = 1e-6, img.copy()
num = np.zeros_like(x0)
for idx in np.ndindex(x0.shape):
xp = x0.copy(); xp[idx] += eps
num[idx] = (np.sum(conv2d(xp, sobel_x, np.zeros(1)) * g) - np.sum(conv2d(x0, sobel_x, np.zeros(1)) * g)) / eps
flipped = sobel_x[:, :, ::-1, ::-1].transpose(1, 0, 2, 3) # swap in/out channels, rotate 180 degrees
ana = conv2d(g, flipped, np.zeros(1), pad=2)
print("max |numeric - analytic| input gradient:", f"{np.abs(num - ana).max():.2e}")
Output:
edge map:
[[ 0. 36. 36.]
[ 0. 36. 36.]
[ 0. 36. 36.]]
stem output (64, 112, 112) params 9408 MACs 118.0M
dense equivalent weights: 1.21e+11
max |numeric - analytic| input gradient: 2.79e-08
A small CNN in PyTorch, for CIFAR-10-sized images (3×32×32):
import torch.nn as nn
def block(c_in, c_out):
return nn.Sequential(nn.Conv2d(c_in, c_out, 3, padding=1, bias=False),
nn.BatchNorm2d(c_out), nn.ReLU(inplace=True))
model = nn.Sequential(
block(3, 64), block(64, 64), nn.MaxPool2d(2), # 32 -> 16
block(64, 128), block(128, 128), nn.MaxPool2d(2), # 16 -> 8
block(128, 256), block(256, 256),
nn.AdaptiveAvgPool2d(1), nn.Flatten(), nn.Linear(256, 10))
Things to try
- Transpose the image (
img[0].T[None]) and applysobel_x.T: a horizontal-edge detector. Then apply both and combine them as \(\sqrt{g_x^2+g_y^2}\) — the classic gradient-magnitude edge map. - Shift
imgone pixel right (np.roll) and confirm the edge map shifts too (equivariance). Now add a stride of 2 and check whether it still does. - Write the weight gradient \(\partial L/\partial w\) as a
conv2dofimgwithgas the kernel, and verify it numerically. - Count parameters and MACs of the PyTorch model above, layer by layer, by hand; then check
with
sum(p.numel() for p in model.parameters()). - Train the model on CIFAR-10 (torchvision) for 10 epochs with and without the flips-and-crops augmentation; record the gap between training and test accuracy.
In practice¶
- Default building block: 3×3 conv → BatchNorm → ReLU, with residual connections once you go
past ~10 layers. Use
bias=Falsebefore BatchNorm (the BN shift makes it redundant). - Downsample by 2, double the channels — keeps the compute per layer roughly constant.
- Pre-trained backbones beat training from scratch on almost any small vision dataset:
fine-tune a ResNet-50, ConvNeXt or a ViT from
timmortorchvision. Freeze early layers when data is very scarce; their edge and texture filters transfer. - Memory is in the activations, not the weights: early high-resolution layers produce huge feature maps (the stem output above is 802,816 floats per image). Batch size and input resolution are the main levers.
- Use channels-last memory layout and mixed precision on modern GPUs; convolution kernels in cuDNN are fastest that way (mixed precision).
Common misconceptions¶
\"CNNs are translation-invariant\"
Convolutions are translation-equivariant; only pooling makes decisions approximately invariant, and strided downsampling breaks even that for small shifts (Zhang, 2019). Padding also leaks absolute position: networks can tell where the border is.
\"Bigger kernels see more, so use them\"
Two 3×3 layers see as much as one 5×5 with fewer parameters (18C² vs 25C²) and an extra nonlinearity, which is VGG's lesson. Large kernels came back (ConvNeXt uses 7×7 depthwise) only in depthwise form, where they are cheap.
Check yourself¶
A 3×3 convolution with 128 input and 256 output channels: how many weights? How many MACs on a 28×28 output?
Weights \(256\times128\times9 = 294{,}912\) (+256 biases). MACs \(28\times28\times294{,}912 \approx 231\) million.
What is the output size of a 5×5 kernel, stride 2, padding 2 on a 64×64 input?
\(\lfloor(64+4-5)/2\rfloor+1 = \lfloor 31.5\rfloor+1 = 32\).
Why does a 1×1 convolution make sense? It can't see any neighbours.
It mixes channels at each position: a per-pixel fully connected layer shared across space. It changes channel counts cheaply (bottlenecks), adds nonlinearity between spatial convolutions, and is the pointwise half of a depthwise-separable convolution.
Prove that any linear map on 1-D signals that commutes with all shifts is a convolution.
Let \(A\) commute with the shift \(T\), \((T\mathbf x)_p = x_{p-1}\) (circularly). Apply \(A\) to the unit impulse \(\mathbf e_0\) and call the result \(\mathbf h = A\mathbf e_0\). Since \(\mathbf e_q = T^q\mathbf e_0\), \(A\mathbf e_q = T^qA\mathbf e_0 = T^q\mathbf h\), i.e. \((A\mathbf e_q)_p = h_{p-q}\). By linearity \((A\mathbf x)_p = \sum_q x_q h_{p-q}\): a convolution with kernel \(\mathbf h\).
Your segmentation model needs each output pixel to see a 200×200 region, but you can't afford to downsample. What do you use?
Dilated convolutions with exponentially growing dilation (1, 2, 4, 8, …): receptive field grows exponentially with depth while resolution is preserved. Alternatively, an encoder–decoder (U-Net) downsamples for context and upsamples with skip connections to restore detail, or add attention layers for global context.
Hard: why did ViTs need far more data than CNNs to match them, and why does the gap shrink with scale?
A ViT lacks locality and translation equivariance beyond its patch embedding; it must learn from data that nearby patches matter and that patterns repeat across positions. With small data, the CNN's correct built-in assumptions act as a strong prior. With hundreds of millions of images, the ViT can learn those regularities and also exploit long-range interactions the CNN's bias makes hard, so the weaker prior stops costing and starts paying.
Go deeper¶
Papers
- Gradient-Based Learning Applied to Document Recognition — LeCun, Bottou, Bengio and Haffner, 1998. LeNet-5 and the case for learned features; Section II is the CNN.
- ImageNet Classification with Deep Convolutional Neural Networks — Krizhevsky, Sutskever and Hinton, NeurIPS 2012. AlexNet; Section 3 lists the tricks, each of which became standard.
- Very Deep Convolutional Networks for Large-Scale Image Recognition — Simonyan and Zisserman, 2014. VGG; the 3×3 argument is in Section 2.3.
- Going Deeper with Convolutions — Szegedy et al., 2014. Inception/GoogLeNet.
- Network In Network — Lin, Chen and Yan, 2013. 1×1 convolutions and global average pooling.
- Visualizing and Understanding Convolutional Networks — Zeiler and Fergus, 2013.
- MobileNets — Howard et al., 2017. Depthwise-separable convolutions; Section 3.1 has the cost derivation.
- EfficientNet — Tan and Le, 2019. Compound scaling.
- A ConvNet for the 2020s — Liu et al., 2022. ConvNeXt; Figure 2 is a step-by-step ablation from ResNet to ConvNeXt.
- Understanding the Effective Receptive Field — Luo, Li, Urtasun and Zemel, 2017.
- Making Convolutional Networks Shift-Invariant Again — Richard Zhang, 2019.
- A guide to convolution arithmetic for deep learning — Dumoulin and Visin, 2016. Every padding/stride/dilation/transposed case, with diagrams.
Videos and lectures
- But what is a convolution? — 3Blue1Brown. Convolution from probability to image filters, beautifully animated.
- CS231n: Deep Learning for Computer Vision — Stanford. The course that taught a generation CNNs; its convolutional networks notes are the best single written reference.
Articles and blog posts
- Feature Visualization — Olah, Mordvintsev and Schubert, Distill 2017.
Courses and books
- Deep Learning, chapter 9: Convolutional Networks — Goodfellow, Bengio and Courville. Equivariance, pooling and the neuroscience link.
- Dive into Deep Learning, chapter 7: CNNs — From-scratch implementations.
Code
- vdumoulin/conv_arithmetic — The animations everyone borrows.
- huggingface/pytorch-image-models (timm) — Hundreds of CNN and ViT architectures with pre-trained weights.
Where this leads¶
- Residual connections and very deep networks — the fix that made 152-layer CNNs (and every transformer) trainable.
- Vision transformers and CLIP — what happens when you swap convolution's bias for attention and scale the data.
- Diffusion models — where the convolutional U-Net became the engine of image generation.
- Interpretability — feature visualisation grew into circuit-level analysis.
- How a GPU works — why convolutions' arithmetic intensity suits GPUs.