Search

Search papers and lessons

Going deeper with convolutions

Christian Szegedy, Wei Liu, Yangqing Jia et al. · 2014

GoogLeNet (2014) is a 22-layer image classifier built from Inception modules that reached a 6.67% top-5 error on ImageNet 2014 with about 1.5 billion multiply-adds per image.

On this page

  • Colour = topic mix
  • Calculus
  • Discrete math
  • Neural network basics
  • Architectures
  • Linear algebra
  • Probability
  • ReadReady to readNot yet

TL;DR

GoogLeNet is a 22-layer convolutional network for recognising the content of photos. It won the classification track of the ImageNet Large-Scale Visual Recognition Challenge 2014 with a top-5 error of 6.67%. Its main building block, the Inception module, runs several filter sizes side by side on the same input and joins the results, using 1 by 1 convolutions to keep the cost down.

Builds on: Convolutional Neural Network, Max Pooling, Rectified Linear Unit (ReLU), Softmax · Leads to: Inception Module, Pointwise (1x1) Convolution

Why it mattered

The paper showed that a deeper network can be more accurate without being more expensive, if the layers are designed to spend computation well. The submitted model used about 1.5 billion multiply-adds at inference time, and the paper reports that it had 12 times fewer parameters than the winning 2012 network of Krizhevsky et al., while being more accurate.

The ideas kept spreading. The 1 by 1 convolution as a channel-reducing step before an expensive convolution became a standard bottleneck pattern in later image networks. The paper's choice to replace the large fully connected classifier with average pooling, plus one linear layer, also became a common pattern. In the paper's own words, the design was aimed at inference on individual devices, including devices with limited memory, which is why efficiency is treated as a first-class goal next to accuracy.

The problem

Before this work, the standard recipe for a better image network was to make it bigger: more layers and more filters per layer. The paper names two problems with that recipe.

  1. More parameters means more chances to overfit, and labelled training data is expensive. The paper notes that fine-grained categories in ImageNet are hard even for human raters.
  2. Computation grows quickly. If two convolutional layers are chained, a uniform increase in the number of filters in both causes a quadratic increase in work. If the extra capacity is used poorly, much of that work is wasted.

The paper also points to theory. Arora et al. (2013) show that, under strong conditions, a data distribution that a large sparse network can represent can be captured by a network built layer by layer from clusters of correlated units. The obstacle is hardware: today's libraries are fast at dense matrix multiplication and slow on irregular sparse structures. The paper asks for a compromise that is sparse in its structure but built from dense operations.

How it works

The walkthrough below follows one image through the network in pipeline order. Each Inception module is itself a small pipeline, shown in the diagram.

flowchart LR
  I[Input from previous stage<br/>H x W x C] --> A[1 by 1 conv]
  I --> B[1 by 1 conv reduce] --> B2[3 by 3 conv]
  I --> C[1 by 1 conv reduce] --> C2[5 by 5 conv]
  I --> D[3 by 3 max pool] --> D2[1 by 1 conv projection]
  A --> O[Concatenate along channels]
  B2 --> O
  C2 --> O
  D2 --> O
  1. Input. The network takes a 224 by 224 RGB image with mean subtraction. Every unit in the first layers sees a patch of the image, and the paper's stated receptive field of the whole network is 224 by 224.
  2. Stem. A 7 by 7 convolution with stride 2 produces 112 by 112 by 64. A 3 by 3 max pool with stride 2 halves the grid to 56 by 56 by 64. A 3 by 3 convolution makes 56 by 56 by 192, and another stride-2 max pool gives 28 by 28 by 192. Table 1 of the paper lists these layers, and the first two stages are ordinary convolutions, not Inception modules.
  3. Stage at 28 by 28. Two Inception modules, called 3a and 3b, take 192 channels in and produce 256 and then 480 channels. A stride-2 max pool then gives 14 by 14 by 480.
  4. Stage at 14 by 14. Five Inception modules, 4a to 4e. Two small auxiliary classifiers are attached to 4a and 4d for training only. The stage ends at 7 by 7 by 832.
  5. Stage at 7 by 7. Two Inception modules, 5a and 5b, give 7 by 7 by 1024.
  6. Classifier. A 7 by 7 average pool gives one 1024-value vector. Dropout with a 40% ratio is applied, then a linear layer produces 1000 scores, one per class, and softmax turns them into probabilities.
  7. Training. Asynchronous stochastic gradient descent with momentum 0.9. The learning rate falls by 4% every 8 epochs. Polyak averaging of the weights gives the model used at test time.
  8. Testing. Each image is resized at 4 scales, cropped into 144 views in total, and the softmax outputs are averaged over views and over 7 models.

Check the channel arithmetic on module 3a. Its input is the 192 channels from step 2. Its four branches output 64 channels (1 by 1), 128 channels (3 by 3), 32 channels (5 by 5) and 32 channels (pool projection). Concatenating them gives 64 + 128 + 32 + 32 = 256 channels, which is the 28 by 28 by 256 in the table. Module 3b gives 128 + 192 + 96 + 64 = 480, matching its output row.

The math

Write an input feature map as X\mathbf{X} with height HH, width WW and CinC_{\text{in}} channels. A convolution with a k×kk \times k kernel that produces CoutC_{\text{out}} channels, applied at stride 1 with padding that keeps the grid size, costs this many multiply-adds:

cost=H⋅W⋅k2⋅Cin⋅Cout\text{cost} = H \cdot W \cdot k^2 \cdot C_{\text{in}} \cdot C_{\text{out}}

Each output position needs k2Cink^2 C_{\text{in}} multiplications for each of the CoutC_{\text{out}} filters, and there are HWH W positions. ReLU is applied after each convolution in the paper, and it adds no multiply-adds to this count.

Step 2 in symbols (the Inception module). An Inception module with input X\mathbf{X} computes four branches and joins them along the channel axis:

Y=concat⁡( conv1×1(X),  conv3×3(conv1×1(X)),  conv5×5(conv1×1(X)),  conv1×1(pool3×3(X)) )\mathbf{Y} = \operatorname{concat}\big(\,\mathrm{conv}_{1 \times 1}(\mathbf{X}),\; \mathrm{conv}_{3 \times 3}(\mathrm{conv}_{1 \times 1}(\mathbf{X})),\; \mathrm{conv}_{5 \times 5}(\mathrm{conv}_{1 \times 1}(\mathbf{X})),\; \mathrm{conv}_{1 \times 1}(\mathrm{pool}_{3 \times 3}(\mathbf{X}))\,\big)

The output depth is the sum of the four branch widths: Cout=C1+C3+C5+CpC_{\text{out}} = C_1 + C_3 + C_5 + C_p. The paper's names for these widths are the columns of Table 1: the 1 by 1 width, the 3 by 3 width, the 5 by 5 width and the pool projection width. The reduction layers in front of the 3 by 3 and 5 by 5 convolutions are the "reduce" columns, and they change only the intermediate width.

Step 3 in symbols (why the reduction helps). Take an input with Cin=192C_{\text{in}} = 192 channels, a 5 by 5 convolution to 3232 channels, and compare two ways of doing it per output position. These are illustrative numbers chosen for this lesson, not figures from the paper.

  • Direct: 5⋅5⋅192⋅32=153,6005 \cdot 5 \cdot 192 \cdot 32 = 153{,}600 multiply-adds.
  • With a 1 by 1 reduction to 16 channels: 1⋅1⋅192⋅16=3,0721 \cdot 1 \cdot 192 \cdot 16 = 3{,}072 for the reduction, plus 5⋅5⋅16⋅32=12,8005 \cdot 5 \cdot 16 \cdot 32 = 12{,}800 for the 5 by 5 step, total 15,87215{,}872.

The reduced version is about 9.7 times cheaper for the same output width.

Step 7 in symbols (the training objective). The paper adds auxiliary losses to the total loss with weight 0.3. If LmainL_{\text{main}} is the loss at the final classifier and Laux(a)L_{\text{aux}}^{(a)}, Laux(d)L_{\text{aux}}^{(d)} are the losses at the two side branches, the quantity minimised is

L=Lmain+0.3 (Laux(a)+Laux(d))L = L_{\text{main}} + 0.3\,\big(L_{\text{aux}}^{(a)} + L_{\text{aux}}^{(d)}\big)

The side classifiers are removed at inference time, so the test-time cost is only the main path.

Results

All numbers below are copied from the paper's tables and text.

  • Classification, ILSVRC 2014 (Table 2, top-5 error on the test set). SuperVision (2012) 16.4% without external data and 15.3% with ImageNet 22k data; Clarifai (2013) 11.7% and 11.2%; MSRA (2014) 7.35%; VGG (2014) 7.32%; GoogLeNet (2014) 6.67% with no external data. The paper ranks GoogLeNet first.
  • Effect of testing choices (Table 3, validation set). One model with one crop: 10.07%. One model with 144 crops: 7.89%. Seven models with one crop: 8.09%. Seven models with 144 crops: 6.67%. The last row's cost column lists 1008 units against 1 for the single-view baseline, so the best score is the most expensive one.
  • Detection, ILSVRC 2014 (Table 4). GoogLeNet reached 43.9% mAP with an ensemble of 6 ConvNets, against 40.5% for the 3rd-place entry and 40.7% for the 2nd-place entry. The paper states that its detector used no bounding-box regression and no context model.
  • Single-model detection (Table 5). GoogLeNet reached 38.02% mAP with one model. The paper also reports that the top single model, Deep Insight, gained only 0.3 points from an ensemble of 3 models, while GoogLeNet gained much more from its ensemble.
  • Other reported effects. Replacing the fully connected layers with average pooling improved top-1 accuracy by about 0.6%. The authors report that Inception-style networks can be made 2 to 3 times faster than similarly accurate non-Inception networks, but only with careful manual design.

Limits. The 6.67% figure comes from a seven-model ensemble with 144 crops per image, which the authors say may not be needed in real applications. The paper does not show that the sparsity principle from Arora et al. is the reason for the gains. The authors say so directly: it is unclear whether the architecture's quality comes from the guiding principles, and an automated search for similar topologies would be the stronger test. The paper also reports that most individual design choices were tested and were at least locally optimal, which is different from proving they are the best.

Reading guide

Check yourself

QuestionWithout looking back: what does a 1 by 1 convolution do in an Inception module, and why is it placed before the 3 by 3 and 5 by 5 convolutions?Show answer

It mixes information across channels at each position without changing the grid size. Placed before the 3 by 3 and 5 by 5 convolutions, it reduces the number of input channels, so the expensive larger filters do much less work. The paper uses these as dimension reductions and notes that they also include a ReLU.

QuestionAn Inception module has an input of 480 channels. Its four branches output 96 channels (1 by 1), 160 channels (3 by 3), 48 channels (5 by 5) and 64 channels (pool projection). What is the output depth, and how many channels does the pool branch contribute?Show answer

The output depth is 96 + 160 + 48 + 64 = 368 channels. The pool branch contributes 64 channels, after the 3 by 3 max pool and the 1 by 1 projection.

QuestionThe paper adds auxiliary classifiers during training and throws them away at test time. Why, and why does the paper weight their losses at 0.3 instead of 1?Show answer

The paper says the auxiliary classifiers push discrimination into the lower and middle layers, increase the gradient reaching them, and act as a regulariser. The weight of 0.3 keeps them from dominating the main loss, so the final classifier is still trained mainly for the final output.

QuestionA team wants a classifier that runs on a phone with a tight compute budget. Using the paper's logic, which design lever should they try first, and what does the paper's Table 3 suggest about test-time tricks?Show answer

Try the reduction layers and the balancing of depth and width against computation, since the paper says these knobs allow a controlled trade between cost and quality, and that a cheaper, slightly weaker Inception variant is possible. Table 3 suggests that multi-crop testing and ensembles raise accuracy but multiply cost, so on a phone a single model with a single crop is the honest baseline to measure against.

Sources

Read the full paper

Christian Szegedy, Wei Liu, Yangqing Jia et al., 2014. arXiv:1409.4842