◆ AI All-in-One

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
↗ Plan a path here

Read first

Convolutional Neural NetworksResidual Connections

This leads to

—
The full path from zero — 20 concepts before this one
  1. What Is AI?
  2. Vectors
  3. Derivatives and Slopes
  4. Probability Basics
  5. How Machines Learn
  6. Partial Derivatives and Gradients
  7. Matrices and Matrix Multiplication
  8. The Chain Rule
  9. Supervised, Unsupervised and Reinforcement Learning
  10. Gradient Descent
  11. Supervised Learning
  12. Linear Regression
  13. The Perceptron
  14. Logistic Regression
  15. Neural Networks
  16. Convolutional Neural Networks
  17. Backpropagation
  18. Activation Functions
  19. Vanishing and Exploding Gradients
  20. Residual Connections
  21. 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:

  1. 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.
  2. 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.
  3. How do we keep it trainable? ReLU, batch normalisation and residual connections each made deeper stacks train reliably.
28.225.815.311.76.73.63.02.3 human ≈ 5.1ImageNet challenge: winning top-5 error (%)grey: hand-designed features · orange: deep CNNs20102012201420162018202020221998 LeNet-5≈ 60 K params AlexNet8 layers · 61 M VGG-16 & GoogLeNet138 M vs 6.6 M params ResNet152 layers MobileNet4.2 M params EfficientNetB0: 5.3 M ConvNeXtT: 28.6 M
Fig. 1 The ImageNet challenge's winning top-5 error by year (bars), with the architectures that defined each era below. Deep CNNs took over in 2012, and by 2015 the winning error was below a human annotator's estimated 5.1%.

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:

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 5×5×64×64=102,4005 \times 5 \times 64 \times 64 = 102{,}400 weights. Two 3 × 3 layers have 2×3×3×64×64=73,7282 \times 3 \times 3 \times 64 \times 64 = 73{,}728, which is 28% fewer, and they apply two ReLUs instead of one. Three 3 × 3 layers (receptive field 7 × 7) need 27×642=110,59227 \times 64^2 = 110{,}592 weights against 49×642=200,70449 \times 64^2 = 200{,}704 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 7×7×5127 \times 7 \times 512 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 F(x)F(\mathbf{x}) and adds it to its input:

y=ReLU(x+F(x))\mathbf{y} = \mathrm{ReLU}\big(\mathbf{x} + F(\mathbf{x})\big)

Here x\mathbf{x} is the block's input feature map and FF is two or three convolutions with batch normalisation. If a block has nothing useful to add, it can learn F≈0F \approx 0 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.

VGG (2014)small filters, stacked input 3×3 conv 3×3 conv output two 3×3 layers see a 5×5patch with 28% fewerweights than one 5×5 Inception (2014)several filter sizes at once input 1×1 1×1 3×3 1×1 5×5 pool 1×1 concatenate cheap 1×1 convs shrinkchannels before theexpensive filters ResNet (2015)add the input back x 3×3 conv + ReLU 3×3 conv skip x + F(x) layers learn a correction;gradients flow straightthrough the shortcut MobileNet (2017)split space and channels input 3×3 depthwise one filter per channel 1×1 pointwise mixes the channels output 64 → 128 channels:8,768 weights insteadof 73,728 (8.4× fewer)
Fig. 2 Four building blocks and what each added. VGG stacks small filters; Inception runs several filter sizes in parallel behind cheap 1 × 1 convolutions; ResNet adds its input back through a skip connection; MobileNet splits a convolution into a per-channel spatial filter and a 1 × 1 channel mixer.

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 3×3×64+64×128=8,7683 \times 3 \times 64 + 64 \times 128 = 8{,}768 weights instead of 3×3×64×128=73,7283 \times 3 \times 64 \times 128 = 73{,}728, 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

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

  1. Using the count function, 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?
  2. Remove the x + from BasicBlock.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?
  3. Harder: add a squeeze-and-excitation step to BasicBlock: global-average-pool the output of self.body, pass it through Linear(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 256⋅64+9⋅64⋅64+64⋅256=69,632256 \cdot 64 + 9 \cdot 64 \cdot 64 + 64 \cdot 256 = 69{,}632 weights; two 3 × 3 layers at 256 channels have 2⋅9⋅2562=1,179,6482 \cdot 9 \cdot 256^2 = 1{,}179{,}648.

Check your understanding

5 quick questions. Pick an answer to see whether you were right and why. Your best score is saved on this device.

  1. With 64 input and 64 output channels (no biases), how do two stacked 3 × 3 convolutions compare with one 5 × 5 convolution?

  2. Inside an Inception module, a 1 × 1 convolution shrinks 256 channels to 64 before a 5 × 5 filter runs. What does the 1 × 1 convolution actually do?

  3. A plain 56-layer network has higher training error than a 20-layer one. What did ResNet do about it?

  4. You need a backbone for a phone app with little compute. Which design idea matters most?

  5. Paper A says model X beats model Y by 1% top-1. What should you check before switching?

Finished this chapter?

Learn more

Hand-picked courses, books, videos and tutorials for going deeper. See all resources →

Book

Dive into Deep Learning

Zhang, Lipton, Li & Smola · Intermediate · Free

An interactive book with maths, figures and runnable PyTorch code for every chapter. Many universities use it.

Paper

Going Deeper with Convolutions

Szegedy et al. (Google) · 2014 · Advanced · Free

Introduced the Inception module and GoogLeNet, the 22-layer winner of ImageNet 2014, which used 1 × 1 convolutions to stay cheap.

Paper

A ConvNet for the 2020s

Liu et al. (Meta AI and UC Berkeley) · 2022 · Advanced · Free

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