Back to paper library

Inception-v3

Big Kernels Bow Out

Original paper

Rethinking the Inception Architecture for Computer Vision

Paper authors

Christian Szegedy · Vincent Vanhoucke · Sergey Ioffe · Jonathon Shlens · Zbigniew Wojna

Publication
CVPR 2016Conference
First submitted to arXiv
arXiv:1512.00567
Cite this paper · BibTeX

The citation identifies the linked source version. It cites the original paper and its authors.

@misc{classiccnnsinceptionv32015,
  title = {{Rethinking the Inception Architecture for Computer Vision}},
  author = {Christian Szegedy and Vincent Vanhoucke and Sergey Ioffe and Jonathon Shlens and Zbigniew Wojna},
  year = {2015},
  eprint = {1512.00567},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1512.00567}
}
On this page

When GoogLeNet won the ILSVRC 2014 classification challenge, it used only about 5 million parameters, a twelfth of AlexNet's.

That efficiency is tempting, but anyone who tries to modify it soon runs into trouble. The GoogLeNet paper doesn't clearly explain how each design decision was reached, and the Inception module has many branches. The most intuitive way to scale the model up is to double the number of filters in every group, which quadruples both computation and parameters.

In December 2015, Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, and Jonathon Shlens of Google, together with Zbigniew Wojna of University College London, released this paper. The “Rethinking” in the title refers to taking Inception apart and thinking it through again, to find which approaches make the extra computation worthwhile as the network grows.

Defining the Problem

The authors want to know how a network should be scaled up when the compute budget is limited.

From a large number of architecture experiments, they distilled four principles. The authors themselves are cautious, saying the principles are still partly speculative, that more experiments are needed to establish where they apply, and that they should be consulted only when in doubt. Still, in their experiments, networks that clearly violated them tended to get worse, and got better again once corrected.

  1. Avoid representational bottlenecks, especially early in the network. From input to output, the size of the representation should shrink gradually instead of being squeezed flat all at once at some layer. The authors also note that dimensionality is only a rough estimate of information content.
  2. Higher-dimensional representations are easier to process locally. More activations per position make features easier to disentangle, and training goes faster.
  3. Spatial aggregation can be done in lower dimensions. For example, reducing the number of channels before a 3×33\times3 convolution doesn't hurt expressiveness much. The authors guess that outputs at adjacent positions are highly correlated, so little information is lost in the reduction.
  4. Balance width and depth. Increasing both helps; at a fixed computational cost, increasing width and depth together works best.

Much of GoogLeNet's early gain came from heavy use of 1×11\times1 convolutions for dimensionality reduction, which is principle 3. The authors see dimensionality reduction as a special case of “factorizing convolutions,” and next they go looking for other ways to factorize.

Solving the Problem

Splitting 5×5 into Two 3×3 Layers

Large kernels are expensive. With the same numbers of input and output channels, a 5×55\times5 convolution costs 25/9≈2.7825/9\approx2.78 times as much as a 3×33\times3 one.

But large kernels also see farther. Can we get the same field of view with fewer parameters?

The authors look at a 5×55\times5 convolution from another angle, treating each output as a small fully connected network sliding over a 5×55\times5 region of the input. Since this is a vision network, the small network can itself exploit translation invariance and be split into two layers, the first a 3×33\times3 convolution and the second fully connected over the 3×33\times3 grid of the first layer's output. Slide this two-layer mini-network over the whole input, and you get two 3×33\times3 convolutional layers.

Three layers of blue grids stacked together. The bottom layer is a 5×5 input region, the middle is a 3×3 grid, and the top is a single output cell; red lines show the top cell connecting to the whole 3×3 middle region, and each middle cell in turn connecting to a 3×3 region below
Figure 1 from the paper, excerpted from page 3 of the v3 PDF. The mini-network that replaces a 5×55\times5 convolution: one output in the top layer looks at a 3×33\times3 region of the middle layer, and each middle cell in turn looks at a 3×33\times3 region of the input.

First, the savings. With the number of output channels unchanged, two 3×33\times3 layers have (9+9)/25=72%(9+9)/25 = 72\% of the parameters of one 5×55\times5, a saving of 28%. In a convolutional network every weight is used exactly once at each output position, so the computation shrinks by the same proportion. This assumes the middle layer has as many channels as the input, the same simplification the paper makes.

Next, the receptive field. With two stacked 3×33\times3 layers, one output at the top sees a 5×55\times5 region of the input, as far as a single 5×55\times5 layer, except that the middle positions carry more weight: there are 9 paths from the central input point to the output, and only 1 from a corner.

This replacement raises two questions. First, does it lose expressiveness? Second, since what we're factorizing is the linear 5×55\times5 operation, shouldn't the first layer stay linear, without a ReLU?

The authors ran several control experiments. One compares two Inception models, one using a linear activation in the first factorized layer and the other using ReLU in both layers. On the validation set they settle at 76.2% and 77.2% top-1 accuracy, respectively. The authors say the linear version was worse in all their control experiments; their explanation is that the extra nonlinearity lets the network learn more variations, especially with batch normalization.

Splitting Further into 1×n and n×1

By this logic, any kernel larger than 3×33\times3 can be replaced with a chain of 3×33\times3 layers. Can 3×33\times3 itself be split further?

Splitting it into two 2×22\times2 layers saves only 11%. The authors found a better split in asymmetric convolutions. Do a 3×13\times1 first, then a 1×31\times3, and the field of view is still 3×33\times3.

A diagram narrow at the top and wide at the bottom: a 3×3 input region at the bottom, a 3×1 strip of cells in the middle, and a single output cell at the top; red lines show the output first connecting to the 3 middle cells, each of which in turn connects to a whole row of the input
Figure 3 from the paper, excerpted from page 4 of the v3 PDF. The mini-network that replaces a 3×33\times3 convolution: the lower layer is a 3×13\times1 convolution with 3 outputs.

The asymmetric factorization works the same way. A 1×31\times3 followed by a 3×13\times1 also sees a 3×33\times3 region, but needs only 6 multiplications per output and per pair of input and output channels, a third fewer than the 9 of a 3×33\times3; two 2×22\times2 layers need 8, only a ninth fewer. The larger the kernel, the bigger the saving: a 7×77\times7 needs 49, while splitting it into 1×71\times7 plus 7×17\times1 needs only 14.

This trick doesn't work well everywhere, though. The authors found that it does poorly early in the network but works very well on medium-sized feature maps (sides of roughly 12 to 20). The actual network uses 1×71\times7 followed by 7×17\times1 on 17×1717\times17 feature maps:

Diagram of an Inception module: Base at the bottom splits upward into four branches. The leftmost is a 1x1 followed by four layers, 1xn, nx1, 1xn, and nx1; the second is a 1x1 followed by 1xn and nx1; the third is Pool followed by 1x1; the rightmost is just a 1x1. The four branches merge at Filter Concat
Figure 6 from the paper, excerpted from page 5 of the v3 PDF. An Inception module after factorizing the n×nn\times n convolutions; on 17×1717\times17 feature maps, the authors use n=7n=7.

GoogLeNet's original module had four branches, namely 1×11\times1, 3×33\times3, 5×55\times5, and pooling. By comparison, the leftmost branch here amounts to two 7×77\times7 layers, each split into a pair of asymmetric convolutions; the second branch is the split version of a single 7×77\times7 layer. The 35×3535\times35 stage uses the module from Figure 5, which replaces the 5×55\times5 with two 3×33\times3 layers.

At the smallest feature maps, 8×88\times8, the authors use the idea differently:

Diagram of an Inception module: the leftmost branch is 1x1 then 3x3, which then splits into two side-by-side convolutions, 1x3 and 3x1; the second branch is a 1x1 that splits into 1x3 and 3x1; there is also Pool followed by 1x1, and a lone 1x1. All outputs merge at Filter Concat
Figure 7 from the paper, excerpted from page 5 of the v3 PDF. An Inception module with expanded filter outputs, used only on the coarsest, 8×88\times8 feature maps.

Note that 1×31\times3 and 3×13\times1 are side by side here, with both outputs going straight into the final concatenation instead of being chained. This increases the number of output channels to produce high-dimensional representations on the last feature maps, in line with principle 2. The authors use it only at 8×88\times8, reasoning that at this stage the local processing done by 1×11\times1 convolutions matters more than spatial aggregation.

What Auxiliary Classifiers Really Do

GoogLeNet attached two auxiliary classifiers to the middle of the network. The original idea was to send useful gradients to the earlier layers, fighting vanishing gradients and speeding up convergence.

When the authors took another look, that's not what they found. Early in training, the curves with and without auxiliary classifiers are nearly identical; only near the end of training does the network with auxiliary classifiers pull ahead, settling at a slightly higher plateau. Removing the lower of the two auxiliary classifiers didn't hurt the final quality either.

So GoogLeNet's original hypothesis, that the auxiliary branches help the low-level features evolve, is most likely mistaken in the authors' view. They instead view auxiliary classifiers as regularizers. The evidence is that the main classifier performs better when the auxiliary branch has batch normalization or dropout; adding batch normalization to the auxiliary branch gives a 0.4% absolute gain in top-1 accuracy. Inception-v3's auxiliary classifier sits on top of the last 17×1717\times17 feature map.

The authors also remark in passing that this offers weak supporting evidence for the conjecture that batch normalization acts as a regularizer.

Shrinking the Feature Map Without Choking the Information

Convolutional networks usually shrink feature maps with pooling. Suppose we want to turn 35×35×32035\times35\times320 into 17×17×64017\times17\times640. There are two direct ways to do it:

  • Convolve, then pool: first raise the channels from 320 to 640 at 35×3535\times35, then pool. No information gets choked, but the most expensive convolution runs on the large feature map.
  • Pool, then convolve: first pool to 17×1717\times17, then add channels. Much cheaper, but along the way there's a step with only 17×17×32017\times17\times320, which violates principle 1.

A rough estimate with a single 3×33\times3 convolution, going from 35×35×32035\times35\times320 to 17×17×64017\times17\times640: convolving before pooling takes about 2.26 billion multiply-adds, pooling before convolving about 533 million, a difference of more than four times.

The authors' solution is to put a stride-2 convolution and a stride-2 pooling side by side, each shrinking the feature map directly, and then join the channels from the two sides, halving the computation again to about 266 million multiply-adds:

Two diagrams side by side. The left shows the module's operations: Base splits upward into three branches; two are a 1x1 followed by a stride-2 3x3 convolution (one of them with an extra stride-1 3x3 in front), and the third is stride-2 pooling; they merge at Filter Concat. The right shows it in terms of feature map sizes: 35x35x320 splits into a conv side and a pool side, each producing 17x17x320, which are concatenated into 17x17x640
Figure 10 from the paper, excerpted from page 6 of the v3 PDF. Left: an Inception module that shrinks the feature map while increasing the channels; right: the same thing in terms of feature map sizes.

The diagram on the right is the easiest to read. There, 35×35×32035\times35\times320 splits into two paths. The convolution path outputs 17×17×32017\times17\times320, the pooling path also outputs 17×17×32017\times17\times320, and together they make 17×17×64017\times17\times640. The convolution only has to output half the channels, so it costs half as much as even the pool-first approach; and the output has 640 channels from the start, without passing through the squeezed step.

Putting the Pieces Together

The authors assemble these components into a new network:

Table: Excerpted from Table 1 of the paper. Each row's input size is the output size of the row above.
TypeKernel/stride or noteInput size
conv3×33\times3/2299×299×3299\times299\times3
conv3×33\times3/1149×149×32149\times149\times32
conv (padded)3×33\times3/1147×147×32147\times147\times32
pool3×33\times3/2147×147×64147\times147\times64
conv3×33\times3/173×73×6473\times73\times64
conv3×33\times3/271×71×8071\times71\times80
conv3×33\times3/135×35×19235\times35\times192
3 × InceptionAs in Figure 535×35×28835\times35\times288
5 × InceptionAs in Figure 617×17×76817\times17\times768
2 × InceptionAs in Figure 78×8×12808\times8\times1280
pool8×88\times88×8×20488\times8\times2048
linearlogits1×1×20481\times1\times2048
softmaxclassifier1×1×10001\times1\times1000

The first three 3×33\times3 convolutions come from splitting up the traditional 7×77\times7 first layer, the same idea as replacing 5×55\times5 with two 3×33\times3 layers. Between the three Inception stages, modules like the one in Figure 10 shrink the feature maps. The whole network is 42 layers deep.

You might wonder why the input is such an odd number as 299×299299\times299. Following the table's settings, a stride-2 3×33\times3 convolution turns 299 into 149, and the next convolutions and pooling give 147, 73, 71 and 35, finally shrinking to 17 and 8. Every stride-2 layer without padding divides exactly, no row of pixels is dropped, and the path lands on the table's 3535, 1717 and 88. The paper doesn't explain why it chose 299, but this number does make the whole path line up neatly.

Keeping the Model from Getting Too Sure of Itself

The last component has nothing to do with the architecture; it deals with the labels.

For a training image xx, the model computes the probability of each class with a softmax:

p(k∣x)=exp⁡(zk)∑i=1Kexp⁡(zi)p(k\mid x) = \frac{\exp(z_k)}{\sum_{i=1}^{K}\exp(z_i)}

zkz_k are the logits. Writing the ground-truth label distribution as q(k∣x)q(k\mid x), the cross-entropy loss is:

ℓ=−∑k=1Klog⁡p(k) q(k)\ell = -\sum_{k=1}^{K} \log p(k)\, q(k)

Its gradient with respect to the logits is ∂ℓ/∂zk=p(k)−q(k)\partial\ell/\partial z_k = p(k) - q(k), which lies between −1-1 and 11.

Ordinary training uses one-hot labels, with q(y)=1q(y)=1 for the correct class yy and 0 for everything else. To minimize the loss, p(y)p(y) has to equal 1, which is impossible with finite logits, so the only option is for zyz_y to keep pulling further ahead of the other logits.

The authors point out two problems with this. First, the model learns to assign full confidence to every training image, which may not generalize. Second, the gap between the largest logit and the others gets pushed very wide, and since the gradient is bounded, the model has a harder time adapting. Put plainly, the model is too sure of its own predictions.

Their fix is to replace the label distribution:

q′(k∣x)=(1−ϵ) δk,y+ϵ u(k)q'(k\mid x) = (1-\epsilon)\,\delta_{k,y} + \epsilon\, u(k)

u(k)u(k) is a fixed distribution independent of the image; the authors use the uniform distribution u(k)=1/Ku(k)=1/K. This is called label smoothing regularization (LSR). ImageNet has K=1000K=1000 classes, and ϵ=0.1\epsilon=0.1.

If the logits themselves are optimized as parameters, with a one-hot label the gap between the correct class's logit and the others keeps growing, pushed further the longer training runs; with the smoothed label, the gap stops at ln⁡(0.9001/0.0001)≈9.1\ln(0.9001/0.0001)\approx9.1. At the minimum of the loss, p=q′p = q', and under softmax the logit gap between two classes equals the log of their probability ratio.

The authors also offer another way to look at it. Expand the cross-entropy:

H(q′,p)=(1−ϵ) H(q,p)+ϵ H(u,p)H(q', p) = (1-\epsilon)\,H(q, p) + \epsilon\, H(u, p)

This amounts to adding a penalty on top of the original loss, so that the model pays a price whenever the predicted distribution pp strays too far from the uniform distribution uu.

On ILSVRC 2012, adding LSR lowers top-1 error from 23.1% to 22.8% and top-5 from 6.3% to 6.1%.

Training Setup

The authors train with TensorFlow's distributed system, using 50 replicas, each running on one NVIDIA Kepler GPU with a batch size of 32, for 100 epochs.

Early experiments used momentum; the best models switched to RMSProp (decay 0.9, ϵ=1.0\epsilon=1.0). The learning rate is 0.045, multiplied by 0.94 every two epochs. Gradient clipping at 2.0 is used to stabilize training, and evaluation uses a running average of the parameters.

Discussion

Adding One Change at a Time

Table: Excerpted from Table 3 of the paper. ILSVRC 2012 validation set, single crop. From Inception-v2 down, each row includes all the changes above it.
NetworkTop-1 errorTop-5 errorCost (billions of operations)
GoogLeNet29%9.2%1.5
BN-GoogLeNet26.8%–1.5
BN-Inception25.2%7.8%2.0
Inception-v223.4%–3.8
+ RMSProp23.1%6.3%3.8
+ Label Smoothing22.8%6.1%3.8
+ Factorized 7×721.6%5.8%4.8
+ BN auxiliary classifier21.2%5.6%4.8

This table is cumulative, with each row adding one more change on top of the row before. The last row, “BN auxiliary classifier,” means the fully connected layer in the auxiliary classifier also gets batch normalization, not just the convolutional layers. The version with every change added is what the authors call Inception-v3.

The table shows a few things.

  • Switching to the new architecture alone (the Inception-v2 row) lowers top-1 error from BN-Inception's 25.2% to 23.4%, but computation also rises from 2.0 to 3.8.
  • RMSProp and label smoothing add no computation, and each gains about 0.3 percentage points of top-1.
  • Splitting the first-layer 7×77\times7 into three 3×33\times3 layers raises computation from 3.8 to 4.8 and improves top-1 by 1.2 percentage points, the biggest step among the later changes.

Overall, Inception-v3 costs about 2.4 times as much computation as BN-Inception and 3.2 times as much as GoogLeNet.

All evaluations use the 48,238 non-blacklisted images of the ILSVRC 2012 validation set. The authors also tried all 50,000 images; the results differed by about 0.1 percentage points in top-5 error and about 0.2 in top-1.

How Much Does Lower Resolution Cost?

Detection systems often have to classify small patches of an image, where objects are small and blurry. The common belief is that higher input resolution is better, but the authors point out that this mixes up two things, the resolution of the first layer's receptive field and the model's own capacity and computation. If you just shrink the input and leave the model alone, you're using a much cheaper model to solve a harder problem.

So they hold computation fixed and change only the input resolution. When the input gets smaller, they remove early strides or pooling so the later feature maps stay about the same size:

Table: Excerpted from Table 2 of the paper; the adjustments are summarized from the experiment description in Section 9.
Receptive field sizeAdjustmentTop-1 accuracy
79×7979\times79First layer stride 1, no pooling after75.2%
151×151151\times151First layer stride 1, then max pooling76.4%
299×299299\times299First layer stride 2, then max pooling76.6%

The three networks have almost the same computational cost. The lower-resolution networks take longer to train, but their final results aren't far from 299×299299\times299, with 151×151151\times151 trailing by only 0.2 percentage points and 79×7979\times79 by 1.4.

From this, the authors suggest that in detection pipelines like R-CNN, it may be worth using dedicated networks for small objects that are low-resolution but still computationally heavy.

Comparison with Other Models

Single model, multiple crops:

Table: Selected rows excerpted from Table 4 of the paper.
NetworkCropsTop-1 errorTop-5 error
GoogLeNet144–7.89%
VGG–24.4%6.8%
BN-Inception14422%5.82%
PReLU–21.59%5.71%
Inception-v31219.47%4.48%
Inception-v314418.77%4.2%

Multi-model ensembles:

Table: Excerpted from Table 5 of the paper. Inception-v3's 3.58% is a test-set result; everything else comes from the validation set.
NetworkModelsCropsTop-1 errorTop-5 error
VGGNet2–23.7%6.8%
GoogLeNet7144–6.67%
PReLU–––4.94%
BN-Inception614420.1%4.9%
Inception-v3414417.2%3.58%

In the conclusion, the authors compare against the PReLU network of He et al., finding that Inception-v3 cuts top-5 and top-1 error by 25% and 14% relative, while being six times cheaper computationally and using at least five times fewer parameters (which the authors mark as an estimate). The four-model ensemble's top-5 error is about half that of the winning 2014 GoogLeNet ensemble.

Conclusion

This paper reads more like a design notebook. Table 3 adds changes one at a time, so you can see what each one contributes, and the authors candidly label their four design principles as rules of thumb that still need verification.

To wrap up, here are the components this paper left behind:

  1. Split large kernels into small ones: 5×55\times5 becomes two 3×33\times3 layers, and n×nn\times n becomes 1×n1\times n followed by n×1n\times1.
  2. When shrinking feature maps, run convolution and pooling side by side, so information doesn't get choked.
  3. Auxiliary classifiers act more like regularizers.
  4. Label smoothing, so the model isn't too sure of its answers.

Label smoothing is independent of the architecture, takes a few lines of code, and appears in ConvNeXt's training recipe too. In the next version, Inception meets ResNet, and Inception-v4 wires residual connections into its modules.