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.
| stage | output C × H × W | parameters | multiply–adds |
|---|---|---|---|
| block1 | 64 × 112 × 112 | 38.7 k | 1.94 G |
| block2 | 128 × 56 × 56 | 221.4 k | 2.77 G |
| block3 | 256 × 28 × 28 | 1.48 M | 4.62 G |
| block4 | 512 × 14 × 14 | 5.90 M | 4.62 G |
| block5 | 512 × 7 × 7 | 7.08 M | 1.39 G |
| classifier | 1000 × 1 × 1 | 123.64 M | 123.63 M |
| AlexNet | 61.10 M parameters | 714.19 M MACs |
| VGG-16 | 138.36 M parameters | 15.47 G MACs |
| VGG-19 | 143.67 M parameters | 19.63 G MACs |
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.
- 1. VGG uses kernels of size…
- 2. Two stacked 3 × 3 layers see…
- 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.
- 1. Weights of three 3 × 3 layers vs one 7 × 7 (C → C):
- 2. Feature-map side before the classifier:
- 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- 1. Scale jittering resizes the shorter side to…
- 2. Deep VGGs were first trained by…
- 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.
- 1. n stacked 3 × 3 convs have receptive field…
- 2. VGG's error saturated at…
- 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.
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
- K. Simonyan, A. Zisserman (2015). “Very deep convolutional networks for large-scale image recognition.” Proc. ICLR.
- J. Johnson, A. Alahi, L. Fei-Fei (2016). “Perceptual losses for real-time style transfer and super-resolution.” Proc. ECCV.
- L. A. Gatys, A. S. Ecker, M. Bethge (2016). “Image style transfer using convolutional neural networks.” Proc. CVPR.