Search

Search papers and lessons

Inception Module

Level 3 · 13 min read

An inception module runs several convolutions of different sizes side by side on the same input and joins their outputs, using cheap 1 by 1 convolutions to shrink the channels before the expensive ones.

On this page

  • Colour = topic mix
  • Calculus
  • Discrete math
  • Architectures
  • Linear algebra
  • ReadReady to readNot yet

TL;DR

An inception module is a block for image networks that looks at one input with several filter sizes at once. It runs a 1 by 1 convolution, a 3 by 3 convolution, a 5 by 5 convolution and a max-pooling branch in parallel, then stacks their outputs along the channel axis. Before the 3 by 3 and 5 by 5 steps, it uses 1 by 1 convolutions to cut the number of channels, which keeps the cost low. The idea lets a network use several scales of detail in one layer without paying for the biggest filter everywhere.

Builds on: Pointwise (1x1) Convolution, Max Pooling, Convolution · Leads to: GoogLeNet, Residual Connection

Where it's used

The GoogLeNet image classifier. The module was introduced in the 2014 GoogLeNet convolutional network. The paper reports that the submitted model reached a top-5 error of 6.67 percent on the ILSVRC 2014 classification task, which ranked first in that competition. The task has 1000 classes and about 1.2 million training images, so the network had to tell apart fine-grained categories at many sizes.

Phone and embedded image recognition. The paper says the network was built so that inference could run on single devices, including devices with limited compute and memory. A team shipping a camera feature on a phone needs a network that is accurate but does not multiply huge numbers of values per image. The module's channel reduction is one of the reasons the network stayed compact.

Object parts at different sizes. A photo of a dog contains a nose, an ear and a whole dog. A 1 by 1 filter sees a single pixel's colour, a 3 by 3 filter sees a small patch, and a 5 by 5 filter sees a larger region. An inception module lets the next layer see all three at once, instead of forcing the designer to pick one size per layer.

How it works

Take one tiny case. The input is a grid of 4 by 4 pixels with 8 channels, so each pixel holds 8 numbers. We want a 5 by 5 branch that outputs 16 channels. First the direct way, then the module's way.

  1. Direct branch. Apply a 5 by 5 convolution straight to the 8 input channels to get 16 output channels. Each output pixel is a weighted sum over a 5 by 5 window and all 8 input channels, so it takes 5×5×8=2005 \times 5 \times 8 = 200 multiplications for each of the 16 output channels. Check: 200×16=3200200 \times 16 = 3200 multiplications per output pixel.
  2. Shrink first. Apply a 1 by 1 convolution from 8 channels down to 2 channels. Each output pixel now needs 1×1×8=81 \times 1 \times 8 = 8 multiplications per output channel, so 8×2=168 \times 2 = 16 per pixel. Check: the grid is still 4 by 4, and only the channel count changed.
  3. Big filter on the small input. Apply the 5 by 5 convolution from 2 channels to 16 channels. Each output channel needs 5×5×2=505 \times 5 \times 2 = 50 multiplications, so 50×16=80050 \times 16 = 800 per pixel. Check: the output is still 4 by 4 with 16 channels, the same shape as step 1.
  4. Add up the cost. Steps 2 and 3 together take 16+800=81616 + 800 = 816 multiplications per pixel, against 3200 for the direct branch. Check: 3200/8163200 / 816 is about 3.9, so the reduced branch is roughly four times cheaper for the same output shape.
  5. Join the branches. A real module has four branches, each giving a grid of the same height and width. Their channel counts are added, so 4 channels from one branch and 16 from another become 20 channels in the joined output. Check: the spatial size is unchanged, only the channel count grows.
flowchart TD
  X["Input grid, C channels"] --> A["1x1 conv"]
  X --> B1["1x1 reduce"] --> B2["3x3 conv"]
  X --> C1["1x1 reduce"] --> C2["5x5 conv"]
  X --> D1["3x3 max pool"] --> D2["1x1 conv"]
  A --> J["Concatenate channels"]
  B2 --> J
  C2 --> J
  D2 --> J

The step that makes the module work is step 2. A 1 by 1 convolution is a mix of channels at each pixel, with no neighbours involved, and the reduction does the same job that a smaller number of channels does for memory. Only after the cheap shrink does the expensive 5 by 5 filter run.

The math

Definition: Inception module
Given an input with CinC_{\text{in}} channels on an H×WH \times W grid, an inception module computes KK branches Y(k)Y^{(k)}, each with H×WH \times W spatial size and C(k)C^{(k)} output channels, and stacks them along the channel axis: Y=concat⁡(Y(1),…,Y(K))Y = \operatorname{concat}(Y^{(1)}, \dots, Y^{(K)}), which has ∑kC(k)\sum_k C^{(k)} channels.

The definition says the branches all keep the same spatial size, so they can be stacked. Padding makes this happen: a 3 by 3 or 5 by 5 convolution uses padding of 1 or 2 so the output stays H×WH \times W, and the pooling branch uses stride 1 with padding.

Step 1 in symbols: the direct cost

A convolution with a k×kk \times k kernel, CinC_{\text{in}} input channels and CoutC_{\text{out}} output channels costs

M=k2 Cin CoutM = k^2 \, C_{\text{in}} \, C_{\text{out}}

multiplications for each output pixel. Here ⋅\cdot is ordinary multiplication and k2k^2 is the number of positions in the window. In the tiny case k=5k = 5, Cin=8C_{\text{in}} = 8, Cout=16C_{\text{out}} = 16, so M=25⋅8⋅16=3200M = 25 \cdot 8 \cdot 16 = 3200.

Step 2 and 3 in symbols: the reduced branch

The reduced branch first applies a 1 by 1 convolution with rr channels, then a k×kk \times k convolution:

Mred=1⋅Cin⋅r  +  k2⋅r⋅CoutM_{\text{red}} = 1 \cdot C_{\text{in}} \cdot r \;+\; k^2 \cdot r \cdot C_{\text{out}}

With Cin=8C_{\text{in}} = 8, r=2r = 2, k=5k = 5 and Cout=16C_{\text{out}} = 16, the two terms are 8⋅2=168 \cdot 2 = 16 and 25⋅2⋅16=80025 \cdot 2 \cdot 16 = 800, so Mred=816M_{\text{red}} = 816.

Step 4 in symbols: the ratio

The saving is the ratio of the two costs:

MMred=k2 Cin CoutCin r+k2 r Cout\frac{M}{M_{\text{red}}} = \frac{k^2 \, C_{\text{in}} \, C_{\text{out}}}{C_{\text{in}} \, r + k^2 \, r \, C_{\text{out}}}

When rr is much smaller than CinC_{\text{in}} and k2Coutk^2 C_{\text{out}} is large, the reduced branch is much cheaper. In the tiny case the ratio is 3200/816≈3.93200 / 816 \approx 3.9.

Step 5 in symbols: the joined output

If each branch kk produces C(k)C^{(k)} channels, the joined output has

Cout=∑k=1KC(k)C_{\text{out}} = \sum_{k=1}^{K} C^{(k)}

channels on the same H×WH \times W grid. The branches do not add their values. Each keeps its own channels, and the next layer sees all of them.

Worked examples

Example
1. Tiny: the cost of one 1 by 1 shrink

Use one output pixel of the 5 by 5 branch with Cin=8C_{\text{in}} = 8 input channels and Cout=16C_{\text{out}} = 16 output channels, and compare two reduction sizes.

  1. Direct cost: 25×8×16=320025 \times 8 \times 16 = 3200.
  2. Reduce to r=4r = 4 first. The 1 by 1 step costs 8×4=328 \times 4 = 32.
  3. The 5 by 5 step from 4 channels costs 25×4×16=160025 \times 4 \times 16 = 1600.
  4. Total: 32+1600=163232 + 1600 = 1632. Check: this is about half of 3200.
  5. Reduce to r=2r = 2 instead. The 1 by 1 step costs 8×2=168 \times 2 = 16, and the 5 by 5 step costs 25×2×16=80025 \times 2 \times 16 = 800, so the total is 816816. Check: it is about a quarter of 3200.

Interpretation: the smaller the reduction, the cheaper the branch. The reduction also throws information away, so the designer picks rr by balancing cost against how much detail the branch needs to keep.

Example
2. Standard: a module on a 28 by 28 grid

Take an input of 28 by 28 pixels with 192 channels. The module has four branches: a 1 by 1 branch with 64 output channels; a 1 by 1 reduction to 96 channels then a 3 by 3 branch with 128 outputs; a 1 by 1 reduction to 16 channels then a 5 by 5 branch with 32 outputs; and a 3 by 3 max-pool followed by a 1 by 1 branch with 32 outputs. Compare the 5 by 5 branch with and without reduction.

  1. Direct 5 by 5 branch: 25×192×32=153,60025 \times 192 \times 32 = 153{,}600 multiplications per pixel.
  2. Reduced 5 by 5 branch: the 1 by 1 step costs 192×16=3072192 \times 16 = 3072, and the 5 by 5 step costs 25×16×32=12,80025 \times 16 \times 32 = 12{,}800.
  3. Total reduced cost: 3072+12,800=15,8723072 + 12{,}800 = 15{,}872 per pixel.
  4. Saving: 153,600/15,872≈9.7153{,}600 / 15{,}872 \approx 9.7, so the reduced branch is about ten times cheaper.
  5. Output channels of the module: 64+128+32+32=25664 + 128 + 32 + 32 = 256.
  6. Output shape: the grid is still 28 by 28, so the output is 28×28×25628 \times 28 \times 256.

Interpretation: the reduction makes the module wide in its outputs without making its largest filter expensive. The module's output has 256 channels, but the most costly filter sees only 16 channels.

Example
3. Realistic: one image through the module

Use the module from example 2 and compute the cost for one whole image, using the reduced and the direct 5 by 5 branch.

  1. The grid has 28×28=78428 \times 28 = 784 pixels.
  2. Direct 5 by 5 branch per image: 784×153,600=120,422,400784 \times 153{,}600 = 120{,}422{,}400 multiplications.
  3. Reduced 5 by 5 branch per image: 784×15,872=12,443,648784 \times 15{,}872 = 12{,}443{,}648 multiplications.
  4. Check the reduced figure: 784×15,872=15,872×800−15,872×16=12,697,600−253,952=12,443,648784 \times 15{,}872 = 15{,}872 \times 800 - 15{,}872 \times 16 = 12{,}697{,}600 - 253{,}952 = 12{,}443{,}648.
  5. Saving for the image: 120,422,400/12,443,648≈9.7120{,}422{,}400 / 12{,}443{,}648 \approx 9.7, the same ratio as per pixel, since every pixel uses the same branch.
  6. Interpretation: for one image the reduction saves about 108 million multiplications in this one branch alone. A network stacks many modules, so the saving multiplies across the whole network.

Try it: the designer lowers the 5 by 5 reduction from 16 channels to 8. How many multiplications per pixel does the reduced 5 by 5 branch now need? Answer: the 1 by 1 step costs 192×8=1536192 \times 8 = 1536, and the 5 by 5 step costs 25×8×32=640025 \times 8 \times 32 = 6400. The total is 1536+6400=79361536 + 6400 = 7936 per pixel.

Common mistakes and tradeoffs

It is tempting to think that a 1 by 1 convolution does nothing useful because it looks at one pixel. In fact it mixes the channels at each position, and with a ReLU after it, it adds a nonlinear step once a ReLU follows it. The module uses it for two jobs at once: cutting the channel count and adding a nonlinearity before the expensive filters.

It is tempting to think that the branches are added together. In fact they are concatenated along the channel axis, so each branch keeps its own channels. The next layer can then weigh the outputs of the 1 by 1, 3 by 3, 5 by 5 and pooling branches separately.

It is tempting to think that a larger reduction is always better because it is cheaper. In fact a reduction that is too small throws away information that the next filter needs. The tradeoff is cost against detail, and it is set per branch.

It is tempting to think that the inception module is a fixed recipe. In fact the exact branch sizes are design choices, and the GoogLeNet paper stacks several modules with different sizes. Later designs often add a batch normalization step to such blocks. The idea of parallel branches with channel reduction is the part that carries over.

When to use it: use an inception module when the input needs features at several scales and compute matters. When not to use it: a plain stack of 3 by 3 convolutions is simpler, and modules add engineering complexity. Alternatives include residual blocks, which add a shortcut rather than new branches, and factorized convolutions, which replace a 5 by 5 filter with a chain of smaller ones.

History

Before 2014, image networks were mostly stacks of one kind of convolution with a fixed filter size. Making them deeper and wider made them more accurate, but also more expensive and more prone to overfitting when labelled examples were limited. The paper builds on the Network-in-Network idea, which adds 1 by 1 convolutions as small learned mixers at each position. Its own contribution was to use the 1 by 1 convolutions mainly as dimension reduction, to remove computational bottlenecks before the larger filters.

Christian Szegedy and colleagues described the inception module in the 2014 paper "Going deeper with convolutions". The paper found that Dropout stayed essential in its classifier even after the fully connected layers were replaced by average pooling. The team named its entry GoogLeNet as a homage to the convolutional network LeNet-5 of Yann LeCun, and it won the ILSVRC 2014 classification challenge with a top-5 error of 6.67 percent. The module caught on because it gave a wider and deeper network at a cost close to that of a smaller one. Later versions of the Inception family kept the parallel-branch idea and added further changes.

Recap

  • An inception module runs several filter sizes in parallel on one input and concatenates their outputs along the channel axis.
  • A 1 by 1 convolution before a 3 by 3 or 5 by 5 convolution cuts the channel count, so the expensive filter sees fewer inputs.
  • The cost of a convolution is k2 Cin Coutk^2 \, C_{\text{in}} \, C_{\text{out}} per output pixel, and the reduction changes that product to a cheaper one.
  • The branches keep the same grid size, so the module's output is their channels stacked together.

What to read next: the GoogLeNet paper builds the full network from these modules, and residual connections show a different way to make deep networks trainable.

Check yourself

QuestionRecall: what does a 1 by 1 convolution do to the channels at each pixel, and why does the inception module put one before its 5 by 5 branch?Show answer
A 1 by 1 convolution mixes the input channels at each pixel without looking at neighbours. The module places one before the 5 by 5 branch to reduce the number of channels, so the expensive 5 by 5 filter runs on fewer inputs and costs less.
QuestionComputation: an input has 64 channels, a 3 by 3 branch outputs 32 channels, and the branch first reduces to 8 channels with a 1 by 1 convolution. How many multiplications per output pixel does the reduced branch need, compared with the direct 3 by 3 branch?Show answer
Direct: 9×64×32=18,4329 \times 64 \times 32 = 18{,}432. Reduced: the 1 by 1 step costs 64×8=51264 \times 8 = 512, and the 3 by 3 step costs 9×8×32=23049 \times 8 \times 32 = 2304, so the total is 512+2304=2816512 + 2304 = 2816. The reduced branch needs 2816 multiplications per pixel, against 18,432 for the direct branch.
QuestionWhy: the branches of an inception module are joined by concatenation along the channel axis, not by adding their values. Why does that matter?Show answer
Concatenation keeps each branch's channels separate, so the next layer can learn different weights for the 1 by 1, 3 by 3, 5 by 5 and pooling outputs. Adding would merge them into one set of channels and throw away which branch each value came from. Concatenation works because every branch keeps the same height and width.
QuestionApplied: a team wants a classifier for a low-power camera, and each branch must keep the same grid size. Their 5 by 5 branch is too expensive. What two design choices can they make to cut its cost, and what is the tradeoff?Show answer
They can add a 1 by 1 reduction before the 5 by 5 convolution, and they can lower the reduced channel count. The tradeoff is that a smaller reduction is cheaper but keeps less information for the 5 by 5 filter to work with, so the team must check the accuracy after each change.

Sources