TL;DR
VGG is a Convolutional Neural Network built by repeating one simple pattern: two or more small 3 by 3 convolutions with ReLU activations, then a Max Pooling step that halves the grid. Stacking that pattern 16 or 19 layers deep, with a fixed design rule at every level, gave a large accuracy gain on the ImageNet classification benchmark in 2014.
Where you'll see it: as a feature extractor for transfer learning, as the perceptual-loss network in many image-generation and style-transfer systems, and as the reference "plain deep network" in papers about residual connections.
Intuition
A recipe, not a new idea
Earlier convolutional networks, such as the ones that won ImageNet in 2012 and 2013, used a mix of filter sizes, strides and normalisation choices. Each design was a one-off. The VGG authors, Karen Simonyan and Andrew Zisserman at Oxford, asked a narrower question: if you fix everything except depth, how much does depth alone help?
Their answer was to use the same tiny building block everywhere. Every convolution is 3 by 3 with stride 1 and padding 1, so it keeps the grid size. Every pooling step is 2 by 2 with stride 2, so it halves the grid. Depth is then just a count of how many times you repeat the block.
flowchart LR
I[224 x 224 x 3 image] --> B1[2 conv 3x3, 64 channels]
B1 --> P1[max pool: 112 x 112]
P1 --> B2[2 conv 3x3, 128 channels]
B2 --> P2[max pool: 56 x 56]
P2 --> B3[3 conv 3x3, 256 channels]
B3 --> P3[max pool: 28 x 28]
P3 --> B4[3 conv 3x3, 512 channels]
B4 --> P4[max pool: 14 x 14]
P4 --> B5[3 conv 3x3, 512 channels]
B5 --> P5[max pool: 7 x 7]
P5 --> H[fully connected layers and softmax]
The shape of the network is a set of blocks. Each block keeps its spatial size, and each pool halves it while the channel count doubles.
Why small filters are enough
A 3 by 3 filter sees a small neighbourhood. Stacking two of them means the second filter sees a 3 by 3 patch of first-layer outputs, and each of those already saw a 3 by 3 patch of the input. The combined view is a 5 by 5 region of the input. Three stacked 3 by 3 layers give a 7 by 7 view. So a stack of small filters covers the same area as one big filter, but with more non-linear steps in between, and with fewer weights. The math below makes the weight count precise.
The math
Notation
Let a convolutional layer take input channels and produce output channels with filters of side . The number of weights in that layer, ignoring biases, is
The receptive field of a layer is the square of input pixels that can affect one output value. For a stack of convolutions of side with stride 1, the receptive field side is
For , this gives . Two layers see a 5 by 5 region, and three see a 7 by 7 region.
Output sizes through the network
With padding 1 and a 3 by 3 kernel, a convolution keeps the height and width. A 2 by 2 max pool with stride 2 maps a side of length to . Starting from a 224 by 224 input, the grid goes 224, 112, 56, 28, 14, and finally 7 after the fifth pool. The last convolutional output is therefore , which flattens to numbers.
Parameter counts
The classifier at the end is three fully connected layers, with 4096, 4096 and 1000 outputs. The first of these maps inputs to outputs, so it holds
weights. The second fully connected layer holds weights, and the last holds . Together these are about 123.6 million weights. The convolutional layers of VGG-16 together hold about 14.7 million. The total is about 138 million, and the fully connected layers account for roughly 89 percent of it.
Training objective
The network outputs 1000 scores, one per ImageNet class, and a Softmax turns them into probabilities. Training minimises the cross-entropy loss with Stochastic Gradient Descent and momentum. Dropout with probability 0.5 is applied to the first two fully connected layers during training. The authors also used weight decay and a learning rate that was divided by 10 when validation accuracy stopped improving.
Worked examples
Take 64 input channels and 64 output channels, and compare two ways to get a 5 by 5 receptive field.
- One 5 by 5 convolution: weights.
- Two 3 by 3 convolutions: each has weights, so the pair has weights.
- Ratio: . The stack uses about 28 percent fewer weights.
- Between the two layers there is a ReLU, so the stack can represent a more complex function of the same 5 by 5 region than a single linear filter can.
- Interpretation: VGG's choice is cheaper and more expressive for the same view of the image, which is why it used only 3 by 3 filters.
Take a input to the fourth block of VGG-16, which has three 3 by 3 convolutions with 512 output channels.
- First convolution: input 256 channels, output 512. Size stays because of padding 1. Weights: .
- Second convolution: input 512, output 512. Weights: .
- Third convolution: same as the second, another weights.
- After the block, a max pool halves the grid to .
- Interpretation: the block adds about 5.9 million weights and halves the spatial area for the next block. Each pool widens the view of every layer after it, so deeper features depend on larger parts of the input.
Tradeoffs and failure modes
VGG is simple to explain and easy to modify, which made it a standard tool for years. It has real costs.
| Situation | Problem | Better choice |
|---|---|---|
| Deploying on a phone or edge device | About 138 million weights and high memory use | MobileNet-style separable convolutions, or a smaller network |
| Training a very deep plain stack from scratch | Gradients fade in the deepest layers, and training stalls | Residual connections, as in [[residual-connection |
| Building a classifier with a large fixed-size input | Fully connected layers force one input size | A global average pooling head |
| Needing a feature extractor only | The large fully connected head is wasted | Use the convolutional part and discard the classifier |
| Wanting high accuracy with low compute | Compute per image is high at 224 by 224 | A more efficient architecture from later work |
Two failure modes are worth knowing. First, the large fully connected layers make the model heavy and prone to overfitting, which is why dropout was needed. Second, the plain deep network is hard to optimise past a certain depth without careful initialisation. The VGG authors trained the shallow 11-layer net first and used its weights to initialise the first four convolutional layers and the last three fully connected layers of the deeper ones; they later found that Glorot-style random initialisation works without this pre-training.
History
Simonyan and Zisserman submitted the VGG work in 2014. It placed second in the classification track of the ILSVRC 2014 challenge (7.3 percent top-5 test error with an ensemble of 7 models), and first in the localisation track. The paper's main contribution was the systematic study of depth: the authors compared configurations from 11 to 19 weight layers (named A to E, plus a variant of A with local response normalisation), built from the same blocks, with 1 by 1 convolutions in one 16-layer variant. Error fell as depth grew from 11 to 19 layers, but the authors report that it saturated at 19, and the 16 and 19 layer versions became the names people still use.
VGG caught on for two reasons. It was simple to implement with the tools of the time, and its pretrained weights were released publicly, so researchers used it as a feature extractor for many tasks. It also showed that a single design rule could scale, which set the pattern for later architecture papers. The gap between VGG and the residual networks that followed in 2015 is one of the clearest lessons in deep learning: plain stacks have a depth limit that skip connections remove.
Check yourself
QuestionRecall: what are the filter size, stride and padding of every convolution in VGG?Show answer
Every convolution uses a 3 by 3 filter with stride 1 and padding 1. Padding 1 keeps the height and width unchanged, so only the pooling steps change the grid size.
QuestionComputation: how many weights does one 3 by 3 convolution with 128 input channels and 128 output channels have, ignoring biases?Show answer
weights.
QuestionWhy: why does VGG use two or three 3 by 3 layers in a row rather than one larger filter?Show answer
A stack of small filters covers the same receptive field as one large filter. Two 3 by 3 layers see a 5 by 5 region, and three see a 7 by 7 region. The stack uses fewer weights: for equal channel counts, two 3 by 3 layers use weights against for one 5 by 5 layer. The stack also has a non-linearity between its layers, so it can represent more complicated functions of the same region.
QuestionApplied: you want to use a pretrained VGG-16 as a feature extractor for medical images of size 512 by 512. Which parts of the network do you keep, and what happens to the feature map size?Show answer
Keep the convolutional part and discard the three fully connected layers, because their input size is fixed to . The convolutional part is size-flexible. A 512 by 512 input passes five pools, so the final map is rather than . You can then use global average pooling over the spatial grid to get a 512-dimensional feature vector, or attach a new head. The weights from ImageNet still transfer, but you should check that the object scale in the medical images matches what the filters were trained to see.