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.
- 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 multiplications for each of the 16 output channels. Check: multiplications per output pixel.
- Shrink first. Apply a 1 by 1 convolution from 8 channels down to 2 channels. Each output pixel now needs multiplications per output channel, so per pixel. Check: the grid is still 4 by 4, and only the channel count changed.
- Big filter on the small input. Apply the 5 by 5 convolution from 2 channels to 16 channels. Each output channel needs multiplications, so per pixel. Check: the output is still 4 by 4 with 16 channels, the same shape as step 1.
- Add up the cost. Steps 2 and 3 together take multiplications per pixel, against 3200 for the direct branch. Check: is about 3.9, so the reduced branch is roughly four times cheaper for the same output shape.
- 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
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 , and the pooling branch uses stride 1 with padding.
Step 1 in symbols: the direct cost
A convolution with a kernel, input channels and output channels costs
multiplications for each output pixel. Here is ordinary multiplication and is the number of positions in the window. In the tiny case , , , so .
Step 2 and 3 in symbols: the reduced branch
The reduced branch first applies a 1 by 1 convolution with channels, then a convolution:
With , , and , the two terms are and , so .
Step 4 in symbols: the ratio
The saving is the ratio of the two costs:
When is much smaller than and is large, the reduced branch is much cheaper. In the tiny case the ratio is .
Step 5 in symbols: the joined output
If each branch produces channels, the joined output has
channels on the same grid. The branches do not add their values. Each keeps its own channels, and the next layer sees all of them.
Worked examples
Use one output pixel of the 5 by 5 branch with input channels and output channels, and compare two reduction sizes.
- Direct cost: .
- Reduce to first. The 1 by 1 step costs .
- The 5 by 5 step from 4 channels costs .
- Total: . Check: this is about half of 3200.
- Reduce to instead. The 1 by 1 step costs , and the 5 by 5 step costs , so the total is . 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 by balancing cost against how much detail the branch needs to keep.
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.
- Direct 5 by 5 branch: multiplications per pixel.
- Reduced 5 by 5 branch: the 1 by 1 step costs , and the 5 by 5 step costs .
- Total reduced cost: per pixel.
- Saving: , so the reduced branch is about ten times cheaper.
- Output channels of the module: .
- Output shape: the grid is still 28 by 28, so the output is .
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.
Use the module from example 2 and compute the cost for one whole image, using the reduced and the direct 5 by 5 branch.
- The grid has pixels.
- Direct 5 by 5 branch per image: multiplications.
- Reduced 5 by 5 branch per image: multiplications.
- Check the reduced figure: .
- Saving for the image: , the same ratio as per pixel, since every pixel uses the same branch.
- 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 , and the 5 by 5 step costs . The total is 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 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.