Going deeper: AlexNet, VGG and Inception
Three networks that made CNNs deep. AlexNet's ReLU and dropout, VGG's stacks of small kernels, and Inception's side-by-side branches, each reduced to the one idea worth keeping.
What runs in CodeSplash
- DNN004AlexNet Explained here
- DNN005VGG Explained here
- DNN006Inception / GoogLeNet Explained here
You will be able to
- Name what AlexNet added to LeNet and why it mattered
- Explain why two 3 × 3 convolutions beat one 5 × 5
- Describe an Inception block and the job of its 1 × 1 convolutions
- Explain global average pooling
AlexNet: same layout, bigger and better trained
ReadAlexNetAlexNetThe 2012 eight-layer CNN that won ImageNet with ReLU, dropout, data augmentation and GPU training. kept LeNet's layout but went to eight layers and a million training images. The ideas that made it train: ReLU instead of tanh, dropout in its large dense layers, flips and crops of the training images, and GPUs.
The program applies ReLU and then dropout with p = 0.5 to six values. Training keeps a random half and doubles them, giving 6 and 8 where ReLU gave 3 and 4; evaluation uses every value unchanged. Dropout is about the only one of these pieces still used as is.
import numpy as np
h = np.maximum(0, np.array([-2., 1., 3., -1., 2., 4.])) # ReLU
keep = np.array([1, 0, 1, 1, 0, 1], dtype=float); p_drop = .5
print(h * keep / (1 - p_drop), h.copy()) # training, then evaluationh <- pmax(c(-2, 1, 3, -1, 2, 4), 0) # ReLU
keep <- c(1, 0, 1, 1, 0, 1); p_drop <- .5
print(list(train = h * keep / (1 - p_drop), evaluation = h))VGG: only 3 × 3 kernels
ReadThe VGG networkVGG networkA CNN built only from stacked 3 × 3 convolutions and pooling; two 3 × 3 layers see as far as one 5 × 5 with fewer weights. uses nothing but 3 × 3 convolutions, stacked two or three deep between poolings. Two stacked 3 × 3 layers see a 5 × 5 patch, the same receptive fieldReceptive fieldHow many past values one output of a convolutional network can see; for a TCN 1 + 2(k − 1)(2^B − 1). as one 5 × 5 layer, with an extra ReLU in between and fewer weights: 18C² against 25C² for C channels in and out.
The reference program checks the shapes: two unpadded 3 × 3 layers turn a 7 × 7 image into 3 × 3, and the center value, 0.490, depends on the central 5 × 5 patch only. VGG's cost was its huge dense layers at the end.
Inception: several kernel sizes at once
ReadAn Inception moduleInception moduleA block that runs convolutions of several sizes side by side and stacks their outputs, with 1 × 1 convolutions to save cost. runs 1 × 1, 3 × 3 and 5 × 5 convolutions side by side on the same input, padded to the same size, and stacks their outputs as channels. The network doesn't have to pick one scale per layer. Cheap 1 × 1 convolutions shrink the channel count first, so the big kernels stay affordable.
The program stacks three fixed branches over a 5 × 5 image into a 5 × 5 × 3 block. GoogLeNet also ended with global average poolingGlobal average poolingAverages each feature map over all positions, giving one number per channel regardless of the image size.: one average per channel instead of VGG's huge dense layers.
Which costs less?
PredictPredict first
With 64 channels in and out, which needs fewer weights: one 7 × 7 convolution, or three stacked 3 × 3 convolutions with the same receptive field?
Reveal
Three 3 × 3 layers: 3 × 9 × 64 × 64 = 110,592 weights against 49 × 64 × 64 = 200,704. They also put two extra nonlinearities in the path.
What runs here
Read| Entry | In CodeSplash |
|---|---|
| AlexNet (DNN004) | Explained here |
| VGG (DNN005) | Explained here |
| Inception / GoogLeNet (DNN006) | Explained here |
Their ideas live on in what does run: the CNN learner uses ReLU, small 3 × 3 kernels and dropout, and the pretrained image models build on residual networks and vision transformers.
Reference · DNN004 · Explained hereAlexNetAlexNet demonstrated large-scale supervised image recognition with a deeper convolutional network, rectified activations, augmentation, and dropout. Reference · DNN005 · Explained hereVGGVGG uses repeated small convolutions to increase depth while keeping the block design simple. It is useful for feature extraction, historical comparisons, and explaining effective receptive fields; Reference · DNN006 · Explained hereInception / GoogLeNetInception concatenates parallel feature branches with different receptive fields and uses bottleneck projections to control cost. It provides a multiscale alternative to simply widening every layer.Check: deeper CNNs
CheckpointCheck yourself
Which pair of changes from AlexNet is still standard in today's networks?
Show the answer
Answer: a
ReLU and dropout stuck. AlexNet's other specifics were replaced by batch norm, small kernels and single-device training.
Check yourself
After ReLU, a unit outputs 3. With dropout p = 0.5, what does it pass on at evaluation time?
Show the answer
Answer: a
Dropout is off at evaluation. During training the unit would pass on 0 or 6.
Check yourself
How large a patch does one output of three stacked 3 × 3 convolutions (stride 1) depend on?
Show the answer
Answer: a
Each layer adds 2 pixels: 3, then 5, then 7.
Check yourself
Why did VGG prefer stacks of 3 × 3 kernels to one large kernel?
Show the answer
Answer: a
Two 3 × 3 layers cost 18C² against 25C² for a 5 × 5 and add a ReLU between them.
Check yourself
What job do the 1 × 1 convolutions in an Inception block do?
Show the answer
Answer: a
A 1 × 1 convolution is a small dense layer applied at every pixel: it changes the number of channels without looking at neighbors.
Check yourself
An Inception block's 1 × 1, 3 × 3 and 5 × 5 branches each output 32 maps of the same size. How many channels does the block output?
Show the answer
Answer: a
The branches are stacked along the channel axis. Padding keeps their heights and widths equal so they can be stacked.
Recap
Recap- AlexNet: LeNet's layout, deeper, with ReLU, dropout, augmentation and GPUs.
- VGG: stacks of 3 × 3 kernels give large receptive fields with fewer weights.
- Inception: parallel kernel sizes, 1 × 1 convolutions to save cost, global average pooling at the end.
- All three are explained here; their ideas run inside the CNN and pretrained image learners.
Concepts in this lesson