Level 3 In-Depth AI · Vision, Audio and Multimodal
Classic CNN Architectures: LeNet to ResNet
A guided tour of the convolutional networks that won ImageNet year after year, from LeNet and AlexNet through VGG, Inception and ResNet to MobileNet, EfficientNet and ConvNeXt, and the one key idea each of them added.
- Level
- ●●●●● Intermediate
- Reading
- 13 min
- To learn it well
- 1 hour to read, an hour to practise
- Builds on
- 20 concepts →
- Quiz
- 5 questions ↓
This leads to
—The full path from zero — 20 concepts before this one
- What Is AI?
- Vectors
- Derivatives and Slopes
- Probability Basics
- How Machines Learn
- Partial Derivatives and Gradients
- Matrices and Matrix Multiplication
- The Chain Rule
- Supervised, Unsupervised and Reinforcement Learning
- Gradient Descent
- Supervised Learning
- Linear Regression
- The Perceptron
- Logistic Regression
- Neural Networks
- Convolutional Neural Networks
- Backpropagation
- Activation Functions
- Vanishing and Exploding Gradients
- Residual Connections
- Classic CNN Architectures: LeNet to ResNet
Read them roughly in this order. See it on the concept map →
Why it matters
When you load a "pretrained backbone" for Image Classification, Object Detection or Image Segmentation, you choose from a menu: ResNet-50, EfficientNet-B0, MobileNetV3, ConvNeXt-T. These names are the result of about ten years of a very public race. Each year from 2010 to 2017 the ImageNet competition rewarded whoever classified 1,000 kinds of objects most accurately, and each winner contributed a design idea that everyone else then copied.
Knowing those ideas lets you read any modern vision architecture, including vision Transformers, which borrowed many of them. It also lets you choose sensibly between the backbones on offer: a phone app wants a MobileNet, a research baseline wants a ResNet-50, and a strong modern CNN is a ConvNeXt.
The intuition
Every network in this chapter has the same skeleton, which Convolutional Neural Networks introduced: blocks of convolutions that shrink the image's height and width while increasing its number of channels, followed by a classifier head. What changed over the years is the design of the block and how many you can stack. You can follow the story through three questions:
- How deep can we go? Deeper networks build more abstract features, but they are harder to train. LeNet had 2 convolutional layers, AlexNet 5, VGG 16 to 19, GoogLeNet 22 and ResNet 152.
- How do we keep the cost down? Every extra layer costs weights and arithmetic. Small filters, 1 × 1 convolutions, global pooling and depthwise convolutions each cut the cost.
- How do we keep it trainable? ReLU, batch normalisation and residual connections each made deeper stacks train reliably.
Key idea Each classic architecture added one reusable idea: AlexNet showed GPUs + ReLU + big data work; VGG used only small 3 × 3 filters; Inception used 1 × 1 convolutions to stay cheap; ResNet added skip connections so very deep nets train; MobileNet split convolutions to run on phones; EfficientNet scaled depth, width and resolution together; ConvNeXt brought Transformer-era design back to CNNs.
How it works
LeNet-5 (1998): the template
Yann LeCun's LeNet-5 read 32 × 32 handwritten digits. It had two convolutional layers, each followed by subsampling (pooling), and then three fully connected layers: about 60,000 weights in all. Every idea of the CNN chapter (local filters, weight sharing, pooling and a hierarchy of features) is already there. What was missing was data and compute to scale it up.
AlexNet (2012): scale, ReLU and GPUs
Krizhevsky, Sutskever and Hinton's AlexNet was LeNet made big: 5 convolutional layers and 3 fully connected ones, about 60 million weights, trained on 1.2 million ImageNet images using two consumer graphics cards. Its key ingredients were:
- ReLU activations () instead of tanh. The paper reported that ReLU networks trained several times faster (Activation Functions).
- GPU training, splitting the network across two GPUs with 3 GB of memory each.
- Dropout in the fully connected layers, and heavy Data Augmentation (random crops and flips), to fight Overfitting and the Bias–Variance Tradeoff.
It won the 2012 challenge with 15.3% top-5 error against 26.2% for the runner-up.
VGG (2014): only 3 × 3
Simonyan and Zisserman asked what happens if you use only 3 × 3 filters and simply go deeper. The insight is that two stacked 3 × 3 convolutions see a 5 × 5 patch of the input, and three see 7 × 7, but with fewer weights and an extra nonlinearity in between.
Worked example. Count the weights for 64 input and 64 output channels (ignoring biases). One 5 × 5 layer has weights. Two 3 × 3 layers have , which is 28% fewer, and they apply two ReLUs instead of one. Three 3 × 3 layers (receptive field 7 × 7) need weights against for one 7 × 7 layer.
VGG-16 is beautifully regular: blocks of 3 × 3 convolutions, with channels doubling (64, 128, 256, 512) each time a max-pool halves the resolution. But it is huge, at 138 million weights. About 124 million of them sit in the three fully connected layers at the end, mostly in the first one, because the final feature map is flattened into 25,088 numbers and connected to 4,096 neurons.
GoogLeNet and Inception (2014): wide and cheap
The 2014 winner, GoogLeNet (22 layers), took a different path. Its Inception module runs 1 × 1, 3 × 3 and 5 × 5 convolutions and a pooling branch in parallel, then concatenates their outputs along the channel axis. The network can then pick up patterns at several scales in the same layer.
That would be expensive, except for the trick that made it famous: the 1 × 1 convolution. A 1 × 1 filter looks at a single pixel position, but across all its channels. It is a small linear layer applied at every position, so it can shrink 256 channels to 64 before the expensive 5 × 5 filter runs. GoogLeNet also replaced VGG's giant fully connected layers with global average pooling: average each final channel over all positions, giving one number per channel, then apply a single linear layer. The result was about 6.6 million weights, roughly a twentieth of VGG-16, for a better score (6.7% top-5 error).
ResNet (2015): going really deep
Researchers found that simply stacking more layers made plain networks worse, even on their training data: a 56-layer network had higher training error than a 20-layer one. This was the degradation problem: deeper stacks were simply harder to optimise. Kaiming He and colleagues' fix was the residual connection. Each block computes a correction and adds it to its input:
Here is the block's input feature map and is two or three convolutions with batch normalisation. If a block has nothing useful to add, it can learn and pass its input straight through. During Backpropagation the gradient flows along the shortcut unchanged, so even the first layers of a 152-layer network get a clean signal.
Deeper ResNets (50 layers and up) use a bottleneck block: 1 × 1 to shrink channels (say 256 to 64), 3 × 3 on the thin version, 1 × 1 to expand back to 256. ResNet won 2015 with 3.57% top-5 error. ResNet-50, with 25.6 million weights, is still the most common baseline backbone.
After ResNet: efficiency
Once accuracy was good enough, attention turned to cost.
- DenseNet (2017) connected each layer to all earlier layers in a block by concatenation, which reuses features and gets good accuracy with fewer weights.
- SENet (2017, the last ImageNet challenge winner) added "squeeze-and-excitation", a tiny side network that reweights channels: an early form of attention.
- MobileNet (2017) introduced phones to deep vision with the depthwise separable convolution. A normal 3 × 3 convolution mixes space and channels at once. A depthwise separable one splits this into a 3 × 3 depthwise convolution (one filter per channel, no mixing) followed by a 1 × 1 pointwise convolution that mixes channels. For 64 input and 128 output channels that is weights instead of , which is 8.4 times fewer, with a similar saving in arithmetic.
- EfficientNet (2019) asked how to make a network bigger. Make it deeper, wider (more channels) or feed it larger images? Tan and Le found that the best answer is all three in fixed proportion, which they called compound scaling. Starting from a small base (B0, 5.3 million weights) found by automated search, they scaled up to B7, which reached 84.3% top-1 with 66 million weights.
ConvNeXt (2022): the CNN strikes back
By 2021 vision Transformers were winning. Liu and colleagues took a ResNet-50 and modernised it one step at a time, using Transformer-era choices: the AdamW optimiser and long training with heavy augmentation, a "patchify" first layer (4 × 4 convolution with stride 4), large 7 × 7 depthwise convolutions, LayerNorm instead of BatchNorm, GELU activations and fewer of them, and an inverted bottleneck. The resulting ConvNeXt matched similarly sized Transformers (ConvNeXt-T reached 82.1% top-1 against 81.3% for Swin-T). The lesson was that much of the Transformers' advantage had come from better training recipes and design details, not from attention alone.
Choosing a backbone
The table gives figures from torchvision's model documentation, measured the same way for every model (ImageNet top-1, single 224-pixel centre crop except where noted, original training recipes):
| Model | Year | Weights | GFLOPs per image | Top-1 |
|---|---|---|---|---|
| AlexNet | 2012 | 61 M | 0.7 | 56.5% |
| VGG-16 | 2014 | 138 M | 15.5 | 71.6% |
| GoogLeNet | 2014 | 6.6 M | 1.5 | 69.8% |
| ResNet-50 | 2015 | 25.6 M | 4.1 | 76.1% |
| MobileNetV2 | 2018 | 3.5 M | 0.3 | 71.9% |
| EfficientNet-B0 | 2019 | 5.3 M | 0.4 | 77.7% |
| ConvNeXt-T | 2022 | 28.6 M | 4.5 | 82.5% |
A GFLOP is a billion arithmetic operations. Notice that VGG-16 costs nearly 40 times as much as EfficientNet-B0 and is less accurate. Training recipes matter too: the same ResNet-50 retrained with a modern recipe gets about 80.9%.
In code
Parameter counts for the three cost-saving ideas, and a miniature ResNet built from residual blocks with global average pooling:
import torch
import torch.nn as nn
def count(m):
return sum(p.numel() for p in m.parameters())
C = 64
# VGG's insight: two 3x3 convs see a 5x5 patch, with fewer weights
print("one 5x5 conv :", count(nn.Conv2d(C, C, 5, padding=2, bias=False))) # 102400
print("two 3x3 convs:", count(nn.Sequential(nn.Conv2d(C, C, 3, padding=1, bias=False),
nn.Conv2d(C, C, 3, padding=1, bias=False)))) # 73728
# MobileNet's insight: depthwise + pointwise instead of a full 3x3 conv
full = nn.Conv2d(C, 128, 3, padding=1, bias=False)
separable = nn.Sequential(nn.Conv2d(C, C, 3, padding=1, groups=C, bias=False), # depthwise
nn.Conv2d(C, 128, 1, bias=False)) # pointwise
print("full 3x3 :", count(full), " separable:", count(separable)) # 73728 8768
# ResNet's insight: add the input back (identity shortcut)
class BasicBlock(nn.Module):
def __init__(self, c):
super().__init__()
self.body = nn.Sequential(
nn.Conv2d(c, c, 3, padding=1, bias=False), nn.BatchNorm2d(c), nn.ReLU(),
nn.Conv2d(c, c, 3, padding=1, bias=False), nn.BatchNorm2d(c))
def forward(self, x):
return torch.relu(x + self.body(x))
net = nn.Sequential(
nn.Conv2d(3, C, 7, stride=2, padding=3, bias=False), nn.BatchNorm2d(C), nn.ReLU(),
nn.MaxPool2d(3, stride=2, padding=1),
*[BasicBlock(C) for _ in range(4)],
nn.AdaptiveAvgPool2d(1), nn.Flatten(), # global average pooling: any input size works
nn.Linear(C, 1000))
x = torch.randn(2, 3, 224, 224)
print(net(x).shape, f"{count(net):,} parameters") # torch.Size([2, 1000]) 370,472 parameters
print(net(torch.randn(2, 3, 160, 200)).shape) # torch.Size([2, 1000])
The last line shows a practical benefit of global average pooling: the network accepts images of any size, because the pooling always produces one number per channel.
The real models are one line each in torchvision (weights download on first use), or in the timm library, which has hundreds of pretrained backbones:
from torchvision.models import resnet50, ResNet50_Weights, efficientnet_b0, EfficientNet_B0_Weights
import timm
resnet = resnet50(weights=ResNet50_Weights.IMAGENET1K_V2) # the improved-recipe weights
effnet = efficientnet_b0(weights=EfficientNet_B0_Weights.DEFAULT)
convnext = timm.create_model("convnext_tiny", pretrained=True)
Common pitfalls
- Comparing numbers from different recipes. A model's accuracy depends heavily on how it was trained: epochs, augmentation, optimiser, resolution. "Model A beats model B" often just means "recipe A beats recipe B". Compare models trained the same way.
- Counting parameters but ignoring compute and memory. Parameters measure storage. Speed depends on FLOPs, memory traffic and how well the operations suit your hardware. Depthwise convolutions have few FLOPs but can run slower on GPUs than their count suggests. Always time on your target device.
- Forgetting the input resolution. EfficientNet-B7 expects 600 × 600 images. Feeding it 224 × 224 wastes the model. Each pretrained model has a native resolution, so check its transforms.
- BatchNorm with tiny batches. ResNets and EfficientNets use batch normalisation, which behaves badly with batches of 1–4 (common when fine-tuning on large images). Freeze the BatchNorm statistics, or use a model with GroupNorm or LayerNorm, such as ConvNeXt.
- Using VGG as a backbone today. It is slow and memory-hungry for its accuracy. It survives mainly in perceptual losses and teaching.
Watch out Benchmark tables mix numbers measured at different resolutions, with different crops and with extra pretraining data such as ImageNet-21k. Before you choose a backbone because of a 1% difference, check that the numbers really are comparable.
Where it leads
- Data Augmentation became as important as architecture. Many of the later gains came from better augmentation and longer training.
- Object Detection and Image Segmentation use these networks as backbones, often adding a feature pyramid on top.
- Vision Transformers replaced convolutions with attention over patches. ConvNeXt shows the two families have converged.
- Quantization and Knowledge Distillation and Small Models shrink these networks further for phones and edge devices.
- Transfer Learning explains how to adapt any of these backbones to your own task.
A bit of history
Kunihiko Fukushima's Neocognitron (1980) already stacked layers of local feature detectors with pooling, inspired by Hubel and Wiesel's studies of the visual cortex, but it was not trained by gradient descent. LeCun's group added Backpropagation in 1989 and refined the design into LeNet-5, published in 1998. For the next decade neural networks were a niche in vision.
AlexNet (2012) ended that. In 2013 the winners (Zeiler and Fergus's ZFNet line of work) mostly tuned AlexNet and showed how to visualise what its filters respond to. 2014 brought VGG and GoogLeNet. In 2015 ResNet and, separately, batch normalisation made depth routine, and ResNet's paper became one of the most cited in all of science. The ImageNet challenge ended in 2017 with SENet's 2.25% top-5 error. Research then moved to efficiency (MobileNet, EfficientNet), to Transformers (2020 onwards) and to the convergence of the two (ConvNeXt, 2022).
Try it
- Using the
countfunction, compute the weights of a bottleneck block (1 × 1 from 256 to 64, 3 × 3 from 64 to 64, 1 × 1 from 64 to 256) and compare with two plain 3 × 3 convolutions at 256 channels. How many times cheaper is the bottleneck?- Remove the
x +fromBasicBlock.forward, stack 20 blocks, and train both versions on the digits task from Image Classification (adapt the first layer to one input channel). Which trains faster?- Harder: add a squeeze-and-excitation step to
BasicBlock: global-average-pool the output ofself.body, pass it throughLinear(c, c // 4), ReLU,Linear(c // 4, c)and a sigmoid, and multiply the feature map by the result channel by channel.Hint for 1: the bottleneck has weights; two 3 × 3 layers at 256 channels have .
Learn more
Hand-picked courses, books, videos and tutorials for going deeper. See all resources →
Stanford CS231n: Deep Learning for Computer Vision
Famous course notes on neural nets, backprop, CNNs and training, written very clearly.
Dive into Deep Learning
An interactive book with maths, figures and runnable PyTorch code for every chapter. Many universities use it.
ImageNet Classification with Deep Convolutional Neural Networks
AlexNet: the GPU-trained CNN that won ImageNet by a huge margin and started the deep learning boom.
Very Deep Convolutional Networks for Large-Scale Image Recognition
The VGG paper. Showed that depth built from plain stacks of 3 × 3 convolutions gives much better accuracy; its simple design is still a common teaching example.
Going Deeper with Convolutions
Introduced the Inception module and GoogLeNet, the 22-layer winner of ImageNet 2014, which used 1 × 1 convolutions to stay cheap.
Deep Residual Learning for Image Recognition
ResNet: skip connections made networks with 100+ layers trainable.
A ConvNet for the 2020s
Modernised a ResNet step by step with design choices borrowed from vision Transformers, and matched them in accuracy with a pure CNN (ConvNeXt).
Facts checked as of 30 November 2026. Fast-moving details (products, prices, laws) change often. · Source: content/entries/vision/cnn-architectures.md