Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Narrow, then wide, then narrow again
A ResNet bottleneck goes wide → narrow → wide. MobileNetV2 flips this. It keeps a narrow stream of information between blocks; each block expands it six times, does its cheap depthwise filtering in the wide space, and squeezes it back. The squeeze has no ReLU, because chopping off negative values in a narrow space throws away information that cannot be recovered. The result is more accurate than MobileNet v1 at half the cost.
MobileNetV2 became the default mobile backbone: SSDLite detectors, DeepLab mobile segmentation, and countless robot and drone perception models use it. Its narrow shortcuts also keep peak memory low on microcontrollers.
- 1. An inverted residual block goes…
- 2. The squeeze back to narrow has…
- 3. The shortcut connects…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.By hand
- Inverted residual block (expansion t = 6):
- 1 × 1 convolution c_in → 6c_in, BN, ReLU6.
- 3 × 3 depthwise convolution with stride s, BN, ReLU6.
- 1 × 1 convolution 6c_in → c_out, BN, no activation.
- Add the input if s = 1 and c_in = c_out.
- Weights: c_in·tc_in + 9·tc_in + tc_in·c_out. For 24 → 24 that is 3,456 + 1,296 + 3,456 = 8,208. At 56 × 56 the block needs about 25.7 M multiply–adds.
- ReLU6: min(max(z, 0), 6), which is bounded and so robust for low-precision arithmetic.
- Network:
- a 32-channel stem;
- 17 inverted residual blocks with bottleneck widths 16, 24, 32, 64, 96, 160 and 320;
- a 1 × 1 convolution to 1,280 channels, global pooling and a classifier.
- In all: 3.4 M weights (3.5 M with BatchNorm in torchvision) and 300 M multiply–adds.
- Memory: only the narrow bottleneck tensors cross block boundaries. A block’s widest tensor (6 × 24 channels at 56 × 56 = 451,584 values) exists only inside the block.
- 1. Expansion factor t:
- 2. ReLU6(9) =
- 3. Weights of a 24 → 24 block (t = 6):
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.MobileNetV2 in code
Exercise 1.
- The block’s output minus its input equalled the projected, depthwise-filtered expansion.
- Changing the output width removed the shortcut.
- The weight count matched 8,208.
Practice.
- torchvision’s
mobilenet_v2has 3,504,872 parameters and 71.9% top-1 accuracy. - Training recipe:
- RMSProp with decay and momentum 0.9 and weight decay 4·10⁻⁵;
- learning rate 0.045, decayed by 0.98 per epoch, batch 96 per worker.
- SSDLite replaces the SSD head’s convolutions by depthwise-separable ones. MobileNetV2 + SSDLite detects objects on COCO with about 4.3 M parameters.
- The width multiplier and resolution apply as in v1.
model = torchvision.models.mobilenet_v2(weights="IMAGENET1K_V2")
block = model.features[3] # an inverted residual block: expand, depthwise, linear project- 1. torchvision MobileNetV2 parameters:
- 2. SSDLite uses separable convs in…
- 3. MobileNetV2's optimiser:
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
Manifold of interest. The paper argues that the information in a layer’s activations lies on a low-dimensional manifold, which can be embedded in a low-dimensional subspace (the bottleneck).
Why the bottleneck must be linear.
- ReLU is linear on the region where it is positive and discards everything else.
- If the input manifold occupies a low-dimensional space, ReLU collapses a large part of it, and the information cannot be recovered.
- If it is first expanded into a high-dimensional space, each point keeps enough positive coordinates for the whole to remain recoverable (exercise 2).
- So nonlinearities belong in the expanded layer, and the narrow projection should be linear.
- In the paper’s ablation, adding ReLU6 to the bottleneck lowered accuracy.
Why invert the residual. Shortcuts between the narrow tensors are cheap to store, and they connect the representations that carry the information; the wide expansion is an implementation detail inside the block. The authors also showed that shortcuts between bottlenecks worked better than shortcuts between expansions.
Memory-efficient inference. Because only bottleneck tensors flow between blocks, an implementation can process the expanded tensor in tiles. That keeps peak memory near the bottleneck size, which is important for small devices.
- 1. ReLU in a low-dimensional space…
- 2. Adding ReLU6 to the bottleneck…
- 3. Narrow shortcuts help…
Level 4: Expert
★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.Does ReLU destroy information in low dimensions?
History.
- M. Sandler, A. Howard, M. Zhu, A. Zhmoginov and L.-C. Chen (2018) introduced MobileNetV2 at CVPR. It reached 72.0% top-1 with 300 M multiply–adds, against 70.6% at 569 M for v1.
- MnasNet and MobileNetV3 (E8-17) and EfficientNet (E8-20) all build on the inverted residual block (“MBConv”).
Exercise 2. A 2-D spiral of 500 points is embedded into n dimensions by a random Gaussian matrix T. ReLU is applied, and we ask how well the spiral can be recovered, using two measures:
- the paper’s pseudo-inverse of T, after the best rescaling;
- the best linear decoder fitted from the ReLU outputs back to the spiral.
Both are averaged over 20 random T.
| dimensions n | pseudo-inverse error (after rescaling) | linear-decoder error | share zeroed by ReLU |
|---|---|---|---|
| 2 | 0.770 | 0.582 | 0.499 |
| 3 | 0.771 | 0.446 | 0.500 |
| 5 | 0.596 | 0.199 | 0.499 |
| 10 | 0.516 | 0.046 | 0.502 |
| 15 | 0.392 | 0.010 | 0.499 |
| 30 | 0.328 | 0.001 | 0.500 |
- ReLU always zeroes half the coordinates, but the damage depends on the dimension. In 2–3 dimensions much of the spiral cannot be recovered (45–58% error); in 15–30 dimensions a linear decoder recovers it almost exactly. Seed 1 gave the same pattern (0.58 down to 0.001).
- The paper’s pseudo-inverse is a cruder decoder. It recovers roughly half the spiral’s scale and a distorted shape, so its error stays at 0.33 even at n = 30; the paper’s figure is qualitative. The information is there, but not in the form the pseudo-inverse reads out.
- Design rule: apply nonlinearities in wide layers and keep narrow bottlenecks linear.
MobileNetV2 in AI, robotics and aerospace
- On-device detection and segmentation: SSDLite and DeepLabv3-MobileNetV2 run on drones, robots and phones.
- Microcontrollers: narrow shortcuts and tiled execution keep peak RAM small enough for tiny devices (for example MCUNet-style deployment).
- Design vocabulary: “MBConv” blocks are the basic unit of most efficient vision networks used onboard.
References
- M. Sandler, A. Howard, M. Zhu, A. Zhmoginov, L.-C. Chen (2018). “MobileNetV2: inverted residuals and linear bottlenecks.” Proc. CVPR.
- A. G. Howard et al. (2017). “MobileNets: efficient convolutional neural networks for mobile vision applications.” arXiv:1704.04861.
- J. Lin et al. (2020). “MCUNet: tiny deep learning on IoT devices.” Advances in NeurIPS.