Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Let the computer design the network, then polish it by hand
MobileNetV3’s designers let a search algorithm pick the blocks, scoring each candidate by its accuracy and by its actual speed measured on a phone. They then added three hand-made improvements:
- a cheaper version of the smooth “swish” activation, built from a clipped ReLU;
- small attention gates that reweight channels;
- a slimmer final stage.
The result was more accurate than MobileNetV2 and faster.
MobileNetV3 is a standard backbone for on-device classification, detection and segmentation (with its LR-ASPP head). The idea of searching against measured latency on the target chip is how many embedded models for robots and drones are now built.
- 1. MobileNetV3's blocks were chosen by…
- 2. The search scored candidates by…
- 3. h-swish is a cheap version of…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.By hand
- Hard sigmoid: ReLU6(z + 3)/6, which is 0 for z ≤ −3, 0.5 at 0 and 1 for z ≥ 3.
- h-swish: z·ReLU6(z + 3)/6. For example h-swish(1) = 4/6 ≈ 0.667, against swish(1) = 1/(1 + e⁻¹) ≈ 0.731.
- SE in a block: after the depthwise convolution, average each channel, apply an FC layer with ReLU (squeezing to 1/4 of the channels) and an FC layer with hard sigmoid, then rescale the channels.
- Efficient last stage:
- originally a 1 × 1 convolution 960 → 1280 runs at 7 × 7 before pooling;
- pooling first runs it at 1 × 1, saving 48·960·1280 ≈ 59 M multiply–adds in that layer (67.7 M → 8.8 M for the last two layers).
- Search reward (MnasNet): ACC(m)·(LAT(m)/TAR)^w, which penalises models slower than the target latency.
- Sizes:
- Large: 5.4 M parameters, 219 M multiply–adds, 75.2% top-1;
- Small: 2.5 M, 56 M, 67.4%.
- 1. Hard sigmoid of 0:
- 2. h-swish(−4):
- 3. Pooling before the 960 → 1280 layer saves a factor of…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.MobileNetV3 in code
Exercise 1.
- h-swish and the hard sigmoid had exact values at the breakpoints.
- The SE gate rescaled each channel by a single factor between 0 and 1.
- Pooling before the 1,280-channel layer cut the last two layers from 67.7 M to 8.8 M multiply–adds.
Practice.
- torchvision has
mobilenet_v3_large(5,483,032 parameters, 75.3% top-1) andmobilenet_v3_small(2,542,856, 67.7%). - h-swish is
nn.Hardswish; the hard sigmoid isnn.Hardsigmoid. - The network uses h-swish only in its deeper half, where feature maps are smaller and the activation’s cost matters less, and ReLU earlier.
- The first layer has 16 filters instead of 32, with h-swish, at no loss of accuracy.
- Segmentation: the LR-ASPP head combines a pooled SE-style branch with a low-resolution branch.
model = torchvision.models.mobilenet_v3_large(weights="IMAGENET1K_V2")
act = nn.Hardswish() # z * ReLU6(z + 3) / 6- 1. PyTorch's h-swish layer:
- 2. h-swish is used in…
- 3. MobileNetV3-Small parameters:
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
Platform-aware search.
- MnasNet’s reinforcement-learning search ran on a factorised hierarchical space, optimising accuracy times a latency penalty measured on a real phone.
- NetAdapt then shrank individual layers’ filter counts step by step, keeping changes that most improved the ratio of accuracy loss to latency gain.
- Measured latency, not operation counts, guided the design, because they differ on real hardware.
Why h-swish.
- Swish (x·σ(x)), found by automated search (Ramachandran et al., 2017), improves accuracy over ReLU in deep networks.
- Its sigmoid needs an exponential, which is slow on mobile CPUs and awkward in fixed-point arithmetic.
- The hard sigmoid uses only ReLU6, an add and a multiply. ReLU6 is available everywhere and quantises exactly.
- The paper found no accuracy loss from the substitution, and a speed gain.
SE in mobile blocks. Channel attention adds little compute but improves accuracy. MobileNetV3 places it after the depthwise layer and squeezes to 1/4 of the expanded width.
Last stage. Feature maps of 7 × 7 make 1 × 1 layers there cost 49 times more than after pooling. Moving the pooling earlier and removing a projection-and-filter pair saved about 11% of total latency with no loss of accuracy.
- 1. NetAdapt adjusts…
- 2. Swish's drawback on mobile:
- 3. The search used…
Level 4: Expert
★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.Is h-swish a good stand-in for swish?
History.
- M. Tan et al. (2019) introduced MnasNet, a platform-aware search.
- T.-J. Yang et al. (2018) introduced NetAdapt.
- P. Ramachandran, B. Zoph and Q. Le (2017) found swish by automated search.
- A. Howard et al. (2019) published MobileNetV3 at ICCV.
Exercise 2. First, the largest and mean gaps between h-swish and swish, and between the hard sigmoid and the sigmoid, on [−8, 8]. Second, a 2–32–32–3 network trained on spirals with each activation (Adam, 300 steps):
| value | |
|---|---|
| max gap, h-swish vs swish | 0.142 |
| mean gap, h-swish vs swish | 0.046 |
| max gap, hard sigmoid vs sigmoid | 0.069 |
| activation | final training loss (seeds 0, 1, 2) | test accuracy |
|---|---|---|
| ReLU | 0.033, 0.023, 0.041 | 0.921, 0.888, 0.919 |
| swish | 0.047, 0.015, 0.039 | 0.919, 0.876, 0.908 |
| h-swish | 0.061, 0.031, 0.070 | 0.928, 0.896, 0.934 |
- h-swish is a close approximation. Its largest gap from swish is 0.14, near z = ±3 where the piecewise form bends, and the hard sigmoid stays within 0.07 of the sigmoid.
- In this small network all three activations performed the same within noise. Mean test accuracy was 0.919 (h-swish), 0.909 (ReLU) and 0.901 (swish); seeds 3 and 4 also showed differences of a few hundredths in both directions.
- The paper’s accuracy gains from swish-type activations come from deep networks. This exercise supports only the narrower claim that h-swish can stand in for swish at no cost in accuracy.
MobileNetV3 in AI, robotics and aerospace
- Latency-targeted search: searching against measured latency on the target chip (an edge TPU, a drone’s processor) is now a common way to build onboard models.
- On-device segmentation: LR-ASPP with MobileNetV3 segments roads, terrain and obstacles in real time on small robots.
- Quantisation-friendly design: activations built from ReLU6 run exactly in 8-bit integer arithmetic on microcontrollers and accelerators.
References
- A. Howard et al. (2019). “Searching for MobileNetV3.” Proc. ICCV.
- M. Tan et al. (2019). “MnasNet: platform-aware neural architecture search for mobile.” Proc. CVPR.
- T.-J. Yang et al. (2018). “NetAdapt: platform-aware neural network adaptation for mobile applications.” Proc. ECCV.
- P. Ramachandran, B. Zoph, Q. V. Le (2017). “Searching for activation functions.” arXiv:1710.05941.