Definition
MobileNet is a family of convolutional networks from Google designed for phones and embedded devices. Nearly all of their spatial filtering is done by cheap depthwise (or ) convolutions, and nearly all of their computation is in convolutions. Three versions matter: V1 (Howard et al., 2017), V2 (Sandler et al., 2018) and V3 (Howard et al., 2019).
By 2016 the accurate ImageNet models (VGG, Inception, ResNet) cost billions of multiply-adds per image, far too much for a phone CPU. Howard et al.'s "MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications" (2017) took a deliberately plain approach. Stack Depthwise separable convolution blocks in a straight line, like VGG. Then give the user two global knobs to trade accuracy for cost. The result reached 70.6% ImageNet top-1 with 569M multiply-adds, close to GoogLeNet's accuracy at about a third of its compute. It became the default backbone for on-device detection (SSD-MobileNet) and segmentation.
Three versions
- V1 (2017)
- stem + 13 depthwise separable blocks, BN + ReLU everywhere; width multiplier , resolution multiplier . 4.2M params, 569M mult-adds, 70.6% top-1
- V2 (2018)
- inverted residual blocks: expand () → depthwise → linear project, ReLU6, residual between bottlenecks. 3.4M params, 300M mult-adds, 72.0% top-1
- V3 (2019)
- block structure found by platform-aware NAS + NetAdapt; h-swish, squeeze-and-excitation, depthwise, cheaper head. Large: 5.4M, 219M, 75.2%; Small: 2.5M, 56M, 67.4%
- Accuracy source
- ImageNet top-1, 224×224 single crop, as reported in each paper
- In PyTorch
torchvision.models.mobilenet_v2,mobilenet_v3_large,mobilenet_v3_small(V1 is intimm, not torchvision)
V1: separable blocks and two multipliers
Each V1 block is a depthwise conv followed by a pointwise conv, each with BatchNorm and ReLU. Downsampling happens with stride 2 in the depthwise conv. Channels go while the map shrinks , then global average pooling and one fully connected layer. Counting depthwise and pointwise separately, the network is 28 layers deep.
The width multiplier thins every layer to channels. The resolution multiplier shrinks the input image (224 → 192, 160, 128), which shrinks every feature map. A block's cost becomes
- width multiplier: cost and parameters scale roughly as (the pointwise term dominates)
- resolution multiplier: cost scales as ; parameters do not change
- the side of the block's output feature map at full resolution
The paper also reports where the work goes: 95% of the multiply-adds and 75% of the parameters are in convolutions. That is good news for speed, because a conv is a plain matrix multiply (GEMM) with no im2col reshuffle. The depthwise convs that do all the spatial filtering account for only about 3% of the compute.
| setting | params (lib) | mult-adds (lib) | paper | top-1 |
|---|---|---|---|---|
| , 224 | 4,210,088 | 568.7M | 4.2M / 569M | 70.6% |
| , 224 | 2,569,144 | 325.4M | 2.6M / 325M | 68.4% |
| , 224 | 1,320,648 | 149.5M | 1.3M / 149M | 63.7% |
| , 224 | 464,600 | 41.0M | 0.5M / 41M | 50.6% |
| , 192 | 4,210,088 | 418.1M | 4.2M / 418M | 69.1% |
| , 160 | 4,210,088 | 290.7M | 4.2M / 290M | 67.2% |
| , 128 | 4,210,088 | 186.4M | 4.2M / 186M | 64.4% |
Two things to read from the table. Accuracy falls smoothly down to and then collapses at . And parameters do not shrink as at small widths: 1,025,000 of the 4.2M parameters are the final FC layer ( plus biases), which only shrinks linearly with .
V2: inverted residuals and linear bottlenecks
Sandler et al. ("MobileNetV2: Inverted Residuals and Linear Bottlenecks", CVPR 2018) changed the block. A ResNet bottleneck is wide → narrow → wide, with the shortcut between the wide ends. MobileNetV2 inverts it: the block input and output are narrow bottlenecks, and the inside is expanded by a factor (6 in the paper) so that the depthwise conv works in a high-dimensional space.
- expansion factor; the first block uses and all others
- , kept for robustness in low-precision arithmetic
- no activation after the projection: the bottleneck stays linear
Why linear? The paper's argument: if the "manifold of interest" lies in a low-dimensional subspace, a ReLU applied in a narrow layer zeroes out whole directions and loses information that later layers cannot recover. Expanding first and applying the ReLU in the wide space loses much less. Applying no ReLU after projecting back to the narrow space loses none. Their ablation found that adding a ReLU after the projection lowers accuracy.
Why connect the narrow ends? The residual shortcut joins the bottlenecks, which carry the information, and the stored tensor between blocks is small. MobileNetV2 has 17 such blocks with widths 16, 24, 32, 64, 96, 160, 320, then a conv to 1280 and the classifier.
Worked example: the 24 → 24 bottleneck at 56×56 (block 3), t = 6
- 1Expand : channels, weights, multiply-adds.
- 2Depthwise on 144 channels: weights, multiply-adds.
- 3Project : , another 3,456 weights and 10,838,016 multiply-adds. No ReLU.
- 4Total 25,740,288 multiply-adds and 8,832 parameters including BatchNorm ( weights ). Stride 1 and , so the input is added to the output. The convs are 84.2% of the block's cost.
V3: searched, with h-swish and squeeze-and-excitation
Howard et al. ("Searching for MobileNetV3", ICCV 2019) kept the inverted residual block and let search tune it. Platform-aware neural architecture search (MnasNet-style, with measured phone latency in the reward) chose the block-level structure, and NetAdapt then trimmed individual layer widths. Several hand-made changes came on top:
- a piecewise-polynomial stand-in for swish , cheap and quantization-friendly; used mainly in the deeper layers
- squeeze-and-excitation (Hu et al., 2018): reweights the expanded channels by a gate computed from their global average
- reduces to 1/4 of the expanded width, then expands back
They also halved the stem to 16 filters and redesigned the expensive last stage: the final expansion moves after global pooling, so it runs on a map instead of . MobileNetV3-Large reports 75.2% top-1 at 219M multiply-adds (5.4M parameters), and V3-Small 67.4% at 56M (2.5M). torchvision's versions have 5,483,032 and 2,542,856 parameters.
1import torch, torch.nn as nn2from torchvision.models import (mobilenet_v2, MobileNet_V2_Weights,3 mobilenet_v3_large, MobileNet_V3_Large_Weights)45class InvertedResidual(nn.Module):6 def __init__(self, cin, cout, stride=1, t=6):7 super().__init__()8 hid = cin * t9 self.use_res = stride == 1 and cin == cout10 layers = []11 if t != 1: # 1x1 expand12 layers += [nn.Conv2d(cin, hid, 1, bias=False), nn.BatchNorm2d(hid), nn.ReLU6(inplace=True)]13 layers += [nn.Conv2d(hid, hid, 3, stride, 1, groups=hid, bias=False), # depthwise 3x314 nn.BatchNorm2d(hid), nn.ReLU6(inplace=True),15 nn.Conv2d(hid, cout, 1, bias=False), nn.BatchNorm2d(cout)] # linear bottleneck16 self.conv = nn.Sequential(*layers)1718 def forward(self, x):19 return x + self.conv(x) if self.use_res else self.conv(x)2021count = lambda m: sum(p.numel() for p in m.parameters())22print(count(InvertedResidual(24, 24))) # 88322324m = mobilenet_v2(weights=MobileNet_V2_Weights.IMAGENET1K_V1).eval()25print(count(m)) # 350487226print(count(mobilenet_v2(width_mult=0.5))) # 1968680: the width multiplier27print(count(mobilenet_v3_large())) # 5483032 (uses nn.Hardswish and SE blocks)2829with torch.no_grad():30 logits = m(torch.randn(1, 3, 224, 224)) # any input side works: global pooling at the endUse when
- +Very low multiply-adds and parameters for their accuracy
- +Width and resolution multipliers give a family of models from one design
- +Most compute is in 1×1 convs, which are plain matrix multiplies
- +Mature tooling: torchvision/timm weights, TFLite and mobile runtimes optimize them
Avoid when
- −Depthwise layers are memory-bound: GPU speed-ups are much smaller than the FLOP savings
- −Lower accuracy than large CNNs or ViTs; degrades sharply
- −Depthwise weights and ReLU6/h-swish make int8 quantization more delicate
- −V3's searched design is tuned for one phone CPU and may not be optimal elsewhere
Check yourself
MobileNetV1 at α = 1, 224×224 costs 569M multiply-adds. Roughly what does α = 0.5 at 224×224 cost?
Check yourself
Why does MobileNetV2 omit the activation after the 1×1 projection of each block?
Remember
- ✓V1: straight stack of depthwise separable blocks; 4.2M params, 569M mult-adds, 70.6% top-1; 95% of compute is convs.
- ✓Width multiplier scales cost by about ; resolution scales cost by and leaves parameters unchanged.
- ✓V2: inverted residuals (narrow → expand → depthwise → narrow) with a linear projection and shortcuts between bottlenecks; 3.4M, 300M, 72.0%.
- ✓V3: NAS + NetAdapt, h-swish, squeeze-and-excitation, a cheaper head; Large 75.2% at 219M mult-adds.
- ✓Low FLOPs do not guarantee low latency: measure on the target device.