Foundations to Frontier
Tests
E. Deep Learning › E8 CNN Architectures (one page each)

MobileNet v3

MobileNetV3 (Howard et al., 2019) was found by searching rather than hand design. Platform-aware architecture search chose the blocks to maximise accuracy under a measured phone latency, and NetAdapt then trimmed each layer. It added squeeze-and-excitation to the inverted residual blocks, the cheap h-swish activation, and a redesigned last stage. MobileNetV3-Large reached 75.2% ImageNet accuracy, 3.2 points above MobileNetV2, with 20% lower latency. This page covers the search, h-swish and the hard sigmoid, SE in mobile blocks, and the efficient last stage. In the exercises you build h-swish, an SE gate and the last stage (49 times cheaper after moving the pooling), then measure h-swish against swish: within 0.14 everywhere, and equal in accuracy within noise in a small network.

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.

Activation lab: the curve, its slope, and what a network learns with it
z from −4 to 4 · orange f · dashed blue f′
hard-swish: training accuracy after 300 steps 0.993
Compare activations at the same number of steps. Smooth, non-saturating units usually fit the spirals fastest. Sigmoid and the hard-threshold units learn slowly or need surrogate gradients. Gated and maxout units use twice as many hidden pre-activations. Learning rates are fixed per activation and not tuned, so treat small differences as noise (press "new data and weights").
Why engineers care

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.

📝 Quick check (Level 0)
0/3 answered
  1. 1. MobileNetV3's blocks were chosen by…
  2. 2. The search scored candidates by…
  3. 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%.
📝 Quick check (Level 1)
0/3 answered
  1. 1. Hard sigmoid of 0:
  2. 2. h-swish(−4):
  3. 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) and mobilenet_v3_small (2,542,856, 67.7%).
  • h-swish is nn.Hardswish; the hard sigmoid is nn.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
🐍 Exercise 1: MobileNetV3's ingredients
Implement the hard sigmoid, h-swish, an SE gate with hard sigmoid, and the cost of the last stage.
📝 Quick check (Level 2)
0/3 answered
  1. 1. PyTorch's h-swish layer:
  2. 2. h-swish is used in…
  3. 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.

📝 Quick check (Level 3)
0/3 answered
  1. 1. NetAdapt adjusts…
  2. 2. Swish's drawback on mobile:
  3. 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.
🐍 Exercise 2 (research): is h-swish a good stand-in for swish?
Measure how closely h-swish and the hard sigmoid approximate swish and the sigmoid, and compare ReLU, swish and h-swish in training.

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

  1. A. Howard et al. (2019). “Searching for MobileNetV3.” Proc. ICCV.
  2. M. Tan et al. (2019). “MnasNet: platform-aware neural architecture search for mobile.” Proc. CVPR.
  3. T.-J. Yang et al. (2018). “NetAdapt: platform-aware neural network adaptation for mobile applications.” Proc. ECCV.
  4. P. Ramachandran, B. Zoph, Q. V. Le (2017). “Searching for activation functions.” arXiv:1710.05941.