Foundations to Frontier
Tests
E. Deep Learning › E8 CNN Architectures (one page each)

VGG-16/19

VGG (Simonyan and Zisserman, 2015) showed that depth matters, using a single, simple rule: only 3 × 3 convolutions, stacked in five stages separated by 2 × 2 max pooling, with channels doubling from 64 to 512. VGG-16 and VGG-19 reached 7.3% top-5 error in ILSVRC 2014, and their uniform design made them the standard feature extractors for years. This page covers the configurations, why stacked 3 × 3 convolutions beat larger kernels, and the cost: 138 million parameters and 15.5 billion multiply–adds. In the exercises you count VGG's parameters and compute, then compare one 5 × 5 convolution against two stacked 3 × 3 convolutions: the stacked version used 28% fewer weights and generalised better in three of five seeds, a modest advantage that initialisation noise easily swamps at this scale.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Deeper, with one simple brick

AlexNet mixed kernel sizes of 11, 5 and 3. The Oxford Visual Geometry Group asked: what if we use only the smallest useful kernel, 3 × 3, and simply stack more layers? Two 3 × 3 layers in a row see a 5 × 5 patch; three see 7 × 7. Their networks, 16 and 19 layers deep, were far more accurate than AlexNet, and their regular design made them easy to understand, reuse and modify.

Architecture explorer: shapes, parameters and compute
stageoutput C × H × Wparametersmultiply–adds
block164 × 112 × 112
38.7 k
1.94 G
block2128 × 56 × 56
221.4 k
2.77 G
block3256 × 28 × 28
1.48 M
4.62 G
block4512 × 14 × 14
5.90 M
4.62 G
block5512 × 7 × 7
7.08 M
1.39 G
classifier1000 × 1 × 1
123.64 M
123.63 M
Total: 138,357,544 parameters (138.36 M), 15.47 G multiply–adds per image at 224 × 224.
AlexNet61.10 M parameters714.19 M MACs
VGG-16138.36 M parameters15.47 G MACs
VGG-19143.67 M parameters19.63 G MACs
Bars show each row's share of the total. Convolutions dominate compute because they run at every position; fully connected layers dominate parameters in older designs (AlexNet, VGG). Changing the input size changes the compute of every convolution but not its parameters. Parameter counts include biases and BatchNorm scale and shift and match torchvision's implementations.
Why engineers care

VGG’s features became the default “backbone” for detection, segmentation and style transfer, and VGG-style perceptual losses are still used to train image generators. Its cost also taught the field to care about efficiency.

📝 Quick check (Level 0)
0/3 answered
  1. 1. VGG uses kernels of size…
  2. 2. Two stacked 3 × 3 layers see…
  3. 3. VGG-16 has 16…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

By hand

  • VGG-16 stages:
    • 2 × 64, 2 × 128, 3 × 256, 3 × 512 and 3 × 512 convolutions;
    • each stage is followed by 2 × 2 max pooling, so 224 → 112 → 56 → 28 → 14 → 7;
    • then fully connected layers 25,088 → 4,096 → 4,096 → 1,000.
  • VGG-19 has 4 convolutions in each of the last three stages.
  • Receptive field of n stacked 3 × 3 convolutions: 1 + 2n (5 for two, 7 for three).
  • Weights for C → C channels:
    • two 3 × 3 layers have 18C² against 25C² for one 5 × 5 (28% fewer);
    • three 3 × 3 layers have 27C² against 49C² for one 7 × 7 (45% fewer);
    • each stacked layer adds a ReLU.
  • Parameters:
    • VGG-16 has 138,357,544, of which 123,642,856 (89%) are in fully connected layers;
    • VGG-19 has 143,667,240.
  • Compute:
    • the first 64 → 64 convolution alone needs 224²·9·64·64 ≈ 1.85 G multiply–adds;
    • the whole of VGG-16 needs about 15.5 G.
📝 Quick check (Level 1)
0/3 answered
  1. 1. Weights of three 3 × 3 layers vs one 7 × 7 (C → C):
  2. 2. Feature-map side before the classifier:
  3. 3. Share of VGG-16's parameters in fc layers:

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.

VGG in code

Exercise 1.

  • The parameter counts matched torchvision exactly (VGG-16: 138,357,544; VGG-19: 143,667,240).
  • The convolutions of VGG-16 need 15.35 G multiply–adds.
  • Two and three stacked 3 × 3 layers have receptive fields of 5 and 7.

Practice.

  • Training recipe:
    • SGD with batch 256, momentum 0.9, weight decay 5·10⁻⁴, and dropout 0.5 in fc6 and fc7;
    • learning rate 0.01, divided by 10 three times over 74 epochs;
    • scale jittering: the image’s shorter side is resized to a random value in [256, 512] before 224 crops are taken.
  • Deep configurations were hard to train from scratch before BatchNorm: the authors initialised them from the shallower 11-layer network. Today use vgg16_bn.
  • As a feature extractor, take the output of conv5_3 or pool5; the 4,096-dimensional fc7 features were popular for retrieval.
model = torchvision.models.vgg16_bn(weights="IMAGENET1K_V1")
features = model.features   # 13 conv layers; output 512 x 7 x 7 for 224 x 224 input
🐍 Exercise 1: counting VGG
Compute VGG-16 and VGG-19 parameters and multiply–adds, and the receptive field of stacked 3 × 3 convolutions.
📝 Quick check (Level 2)
0/3 answered
  1. 1. Scale jittering resizes the shorter side to…
  2. 2. Deep VGGs were first trained by…
  3. 3. Today, to train a VGG from scratch, use…

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory

Why small kernels. A stack of n 3 × 3 convolutions has the receptive field of one (2n + 1) × (2n + 1) convolution. It has nC²·9 weights against (2n + 1)²C², and n ReLUs instead of one. So the stack can represent more complex functions of the same window with fewer parameters. A large kernel is roughly a stack of small ones that has been constrained to be linear between layers.

Depth helps, up to a point. In the paper, error fell from 11 to 16 layers and saturated at 19. Going deeper made training harder: plain stacks degrade beyond about 20 layers, the problem ResNet solved (E8-8).

LRN is unnecessary. The configuration with LRN (A-LRN) was no better than without, so the authors dropped it.

Where the cost is. Parameters sit in the fully connected layers (89%). Compute sits in the early high-resolution convolutions: each stage halves the side (¼ of the positions) and doubles the channels (4 times the weights per position), so every stage up to the 512-channel limit costs roughly the same. Memory for activations is largest in the first stage.

📝 Quick check (Level 3)
0/3 answered
  1. 1. n stacked 3 × 3 convs have receptive field…
  2. 2. VGG's error saturated at…
  3. 3. Each stage up to 512 channels costs roughly…

Level 4: Expert

★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.

Are two 3 × 3 better than one 5 × 5?

History.

  • K. Simonyan and A. Zisserman (2015) introduced VGG; it came second in ILSVRC 2014 classification (7.3% top-5, later 6.8% with two models) and first in localisation.
  • Training took two to three weeks on four GPUs.
  • VGG features underlie the perceptual losses of J. Johnson, A. Alahi and L. Fei-Fei (2016) and the style transfer of L. Gatys, A. Ecker and M. Bethge (2016).

Exercise 2. The network has a 3 × 3 stem (1 → 8 channels) followed by either one 5 × 5 convolution (8 → 8) or two 3 × 3 convolutions (8 → 8 each, ReLU between). Then come 2 × 2 average pooling and a linear output. It is trained with Adam for 200 steps on 300 shifted noisy digits and tested on 1,000:

block after the stem weights train accuracy test accuracy (seeds 0, 1) seeds 2, 3, 4
one 5 × 5 1,600 1.000, 1.000 0.321, 0.437 0.420, 0.371, 0.433
two 3 × 3 1,152 1.000, 1.000 0.389, 0.522 0.349, 0.433, 0.408
  • The stacked block used 28% fewer weights and generalised better in seeds 0, 1 and 3, but worse in seeds 2 and 4. The mean over five seeds was 0.420 against 0.396.
  • The result is sensitive to initialisation. An earlier version of this exercise stored images channels-first, which is mathematically the same network but draws a different random initialisation for the classifier; there the stacked block won all five seeds. With less training data the two were not reliably different.
  • Both memorised the training set, so any difference is in generalisation. VGG’s evidence for small kernels came from ImageNet-scale networks, where it held consistently; at this toy scale the advantage is small and noisy, and a single seed could point either way.
🐍 Exercise 2 (research): two 3 × 3 or one 5 × 5?
Train networks with one 5 × 5 convolution or two stacked 3 × 3 convolutions and compare weights and test accuracy.

VGG in AI, robotics and aerospace

  • Backbones: early versions of Faster R-CNN and SSD (E9) and of FCN and SegNet (E10) used VGG-16, including for vehicle and aircraft detection in aerial images.
  • Perceptual losses: distances between VGG features measure image similarity for super-resolution and image generation.
  • A lesson in cost: VGG-16’s 15.5 G multiply–adds and 528 MB of weights in 32-bit floats pushed the search for efficient networks (MobileNets, E8-15 to E8-17) for robots and drones.

References

  1. K. Simonyan, A. Zisserman (2015). “Very deep convolutional networks for large-scale image recognition.” Proc. ICLR.
  2. J. Johnson, A. Alahi, L. Fei-Fei (2016). “Perceptual losses for real-time style transfer and super-resolution.” Proc. ECCV.
  3. L. A. Gatys, A. S. Ecker, M. Bethge (2016). “Image style transfer using convolutional neural networks.” Proc. CVPR.