{"notes":[{"id":"lightweight/mobilenet-v2","category":"lightweight","legacyPath":"lightweight/1801-mobilenet-v2","legacySlug":"1801-mobilenet-v2","legacyPaths":[],"title":"MobileNet-V2","subtitle":"Refining the Bottleneck","author":"Z. Yuan","paperDate":"2018-01-13","publishedOn":"2024-06-27","paperTitle":"MobileNetV2: Inverted Residuals and Linear Bottlenecks","paperUrl":"https://arxiv.org/abs/1801.04381","bibliography":{"title":"MobileNetV2: Inverted Residuals and Linear Bottlenecks","authors":["Mark Sandler","Andrew Howard","Menglong Zhu","Andrey Zhmoginov","Liang-Chieh Chen"],"url":"https://arxiv.org/abs/1801.04381","pdfUrl":"https://arxiv.org/pdf/1801.04381","codeUrl":null,"preprint":{"id":"1801.04381","submittedOn":"2018-01-13","url":"https://arxiv.org/abs/1801.04381"},"publication":{"venue":"CVPR","year":2018,"kind":"conference","url":"https://arxiv.org/abs/1801.04381"},"citation":"@misc{lightweightmobilenetv22018,\n  title = {{MobileNetV2: Inverted Residuals and Linear Bottlenecks}},\n  author = {Mark Sandler and Andrew Howard and Menglong Zhu and Andrey Zhmoginov and Liang-Chieh Chen},\n  year = {2018},\n  eprint = {1801.04381},\n  archivePrefix = {arXiv},\n  url = {https://arxiv.org/abs/1801.04381}\n}\n","citationPath":"/content/papers/citations/lightweight/mobilenet-v2.a882707cbaa2.bib"},"thumbnail":{"src":"/content/papers/assets/e6bbfb346bb449f83897d76b69c3711d2e9937d40320a7aab0f3843653a688c0.jpg","width":2332,"height":1324},"locale":"en","path":"/content/papers/en/lightweight/mobilenet-v2.db02333fcec2.md","headings":[{"id":"defining-the-problem","text":"Defining the Problem","depth":2},{"id":"nonlinearity-in-narrow-channels","text":"Nonlinearity in Narrow Channels","depth":3},{"id":"where-does-the-residual-shortcut-connect","text":"Where Does the Residual Shortcut Connect?","depth":3},{"id":"solving-the-problem","text":"Solving the Problem","depth":2},{"id":"inverted-residual-and-linear-bottleneck","text":"Inverted Residual and Linear Bottleneck","depth":3},{"id":"why-expand-the-bottleneck","text":"Why Expand the Bottleneck?","depth":3},{"id":"from-block-to-network","text":"From Block to Network","depth":3},{"id":"discussion","text":"Discussion","depth":2},{"id":"imagenet-classification-and-phone-latency","text":"ImageNet Classification and Phone Latency","depth":3},{"id":"other-tasks-and-limits","text":"Other Tasks and Limits","depth":3},{"id":"conclusion","text":"Conclusion","depth":2}],"anchorAliases":{},"guide":null,"relatedReading":[{"id":"lightweight/mobilenet-v1","relation":"background","topic":"Efficient convolution on mobile devices"},{"id":"lightweight/mobilenet-v3","relation":"next","topic":"Efficient convolution on mobile devices"}]},{"id":"lightweight/mobilenet-v1","category":"lightweight","legacyPath":"lightweight/1704-mobilenet-v1","legacySlug":"1704-mobilenet-v1","legacyPaths":[],"title":"MobileNet-V1","subtitle":"Pioneers of Depthwise Separable Convolutions","author":"Z. Yuan","paperDate":"2017-04-17","publishedOn":"2024-06-25","paperTitle":"MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications","paperUrl":"https://arxiv.org/abs/1704.04861","bibliography":{"title":"MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications","authors":["Andrew G. Howard","Menglong Zhu","Bo Chen","Dmitry Kalenichenko","Weijun Wang","Tobias Weyand","Marco Andreetto","Hartwig Adam"],"url":"https://arxiv.org/abs/1704.04861","pdfUrl":"https://arxiv.org/pdf/1704.04861","codeUrl":null,"preprint":{"id":"1704.04861","submittedOn":"2017-04-17","url":"https://arxiv.org/abs/1704.04861"},"publication":null,"citation":"@misc{lightweightmobilenetv12017,\n  title = {{MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications}},\n  author = {Andrew G. Howard and Menglong Zhu and Bo Chen and Dmitry Kalenichenko and Weijun Wang and Tobias Weyand and Marco Andreetto and Hartwig Adam},\n  year = {2017},\n  eprint = {1704.04861},\n  archivePrefix = {arXiv},\n  url = {https://arxiv.org/abs/1704.04861}\n}\n","citationPath":"/content/papers/citations/lightweight/mobilenet-v1.e9c4c525fed4.bib"},"thumbnail":{"src":"/content/papers/assets/b8390bd8e0f21f1b1eaa6b2a5d4a1b0d9eba36e2fe5dd0878830d757839d30f1.jpg","width":1064,"height":1080},"locale":"en","path":"/content/papers/en/lightweight/mobilenet-v1.602fe825c0c0.md","headings":[{"id":"problem-definition","text":"Problem Definition","depth":2},{"id":"solution","text":"Solution","depth":2},{"id":"depthwise-separable-convolution","text":"Depthwise Separable Convolution","depth":3},{"id":"network-architecture","text":"Network Architecture","depth":2},{"id":"training-techniques","text":"Training Techniques","depth":2},{"id":"discussion","text":"Discussion","depth":2},{"id":"cost-of-depthwise-separable-convolution","text":"Cost of Depthwise Separable Convolution","depth":3},{"id":"depth-or-width","text":"Depth or Width?","depth":3},{"id":"comparing-other-models","text":"Comparing Other Models","depth":3},{"id":"conclusion","text":"Conclusion","depth":2}],"anchorAliases":{},"guide":null,"relatedReading":[{"id":"lightweight/mobilenet-v2","relation":"next","topic":"Efficient convolution on mobile devices"}]},{"id":"lightweight/mobilenet-v3","category":"lightweight","legacyPath":"lightweight/1905-mobilenet-v3","legacySlug":"1905-mobilenet-v3","legacyPaths":[],"title":"MobileNet-V3","subtitle":"Custom Architecture Search","author":"Z. Yuan","paperDate":"2019-05-06","publishedOn":"2024-06-29","paperTitle":"Searching for MobileNetV3","paperUrl":"https://arxiv.org/abs/1905.02244","bibliography":{"title":"Searching for MobileNetV3","authors":["Andrew Howard","Mark Sandler","Grace Chu","Liang-Chieh Chen","Bo Chen","Mingxing Tan","Weijun Wang","Yukun Zhu","Ruoming Pang","Vijay Vasudevan","Quoc V. Le","Hartwig Adam"],"url":"https://arxiv.org/abs/1905.02244","pdfUrl":"https://arxiv.org/pdf/1905.02244","codeUrl":null,"preprint":{"id":"1905.02244","submittedOn":"2019-05-06","url":"https://arxiv.org/abs/1905.02244"},"publication":{"venue":"ICCV","year":2019,"kind":"conference","url":"https://arxiv.org/abs/1905.02244"},"citation":"@misc{lightweightmobilenetv32019,\n  title = {{Searching for MobileNetV3}},\n  author = {Andrew Howard and Mark Sandler and Grace Chu and Liang-Chieh Chen and Bo Chen and Mingxing Tan and Weijun Wang and Yukun Zhu and Ruoming Pang and Vijay Vasudevan and Quoc V. Le and Hartwig Adam},\n  year = {2019},\n  eprint = {1905.02244},\n  archivePrefix = {arXiv},\n  url = {https://arxiv.org/abs/1905.02244}\n}\n","citationPath":"/content/papers/citations/lightweight/mobilenet-v3.78d376f40aa4.bib"},"thumbnail":{"src":"/content/papers/assets/09d4bf8776407cb2ac13bc206505f30314b21d2459add8129ffcb929d11ec1bf.jpg","width":1552,"height":588},"locale":"en","path":"/content/papers/en/lightweight/mobilenet-v3.8acef79bee0c.md","headings":[{"id":"defining-the-problem","text":"Defining the Problem","depth":2},{"id":"solving-the-problem","text":"Solving the Problem","depth":2},{"id":"from-the-mobilenetv2-block-to-v3","text":"From the MobileNetV2 Block to V3","depth":3},{"id":"search-first-then-tune-each-layer","text":"Search First, Then Tune Each Layer","depth":3},{"id":"redesigning-the-tail-and-the-stem","text":"Redesigning the Tail and the Stem","depth":3},{"id":"where-is-hard-swish-used","text":"Where Is Hard-Swish Used?","depth":3},{"id":"layer-by-layer-large-and-small-designs","text":"Layer-by-Layer Large and Small Designs","depth":3},{"id":"discussion","text":"Discussion","depth":2},{"id":"imagenet-accuracy-and-device-latency","text":"ImageNet: Accuracy and Device Latency","depth":3},{"id":"development-path-and-downstream-tasks","text":"Development Path and Downstream Tasks","depth":3},{"id":"conclusion","text":"Conclusion","depth":2}],"anchorAliases":{"mobilenet-v2-module":"from-the-mobilenetv2-block-to-v3","mobilenet-v3-module":"from-the-mobilenetv2-block-to-v3","neural-architecture-search":"search-first-then-tune-each-layer","network-tail-modifications":"redesigning-the-tail-and-the-stem","reducing-initial-filters":"redesigning-the-tail-and-the-stem","non-linear-activation-functions":"where-is-hard-swish-used","network-architecture-large":"layer-by-layer-large-and-small-designs","network-architecture-small":"layer-by-layer-large-and-small-designs","imagenet-experiment-results":"imagenet-accuracy-and-device-latency","mobile-device-evaluation":"imagenet-accuracy-and-device-latency","optimization-record":"development-path-and-downstream-tasks"},"guide":null,"relatedReading":[{"id":"lightweight/mobilenet-v2","relation":"background","topic":"Efficient convolution on mobile devices"},{"id":"lightweight/mobilenet-v4","relation":"next","topic":"Efficient convolution on mobile devices"},{"id":"lightweight/senet","relation":"comparison","topic":"Channel attention in lightweight networks"}]}],"text":"The first MobileNet split standard convolution into depthwise and pointwise operations, allowing image classification on mobile devices with fewer multiply-adds. MobileNetV2 asks a further question: can an already narrow feature representation survive another ReLU?\n\nIf a nonlinearity discards information in a narrow representation, making later layers wider cannot recover it. V2 therefore computes in a wider intermediate representation, keeps the final projection back to the narrow bottleneck linear, and connects the narrow ends with a residual shortcut.\n\n\n> [!TIP]\n> \n> If the paper's terminology feels like a flood, I recommend starting with the code. But since you're here, let's look at the diagrams together first. The code below is a teaching feature extractor, not a full reproduction of the paper's training or mobile deployment.\n\n\n## Defining the Problem\n\n### Nonlinearity in Narrow Channels\n\nA convolutional feature tensor has height $h$, width $w$, and $d$ channels. At one spatial position it becomes a $d$-dimensional vector. The paper uses the intuition that useful features may lie near a lower-dimensional manifold: with a suitable representation, a narrow bottleneck may preserve task-relevant information. This is a design hypothesis, not a claim that arbitrary high-dimensional vectors project losslessly to a low-dimensional space.\n\nReLU maps negative values to zero. Try $(-1,1)$ and $(-2,1)$: both become $(0,1)$ and can no longer be distinguished. MobileNetV2 uses ReLU6, which also clips values above 6. Applying such a nonlinearity in an overly narrow representation can lose distinctions that a later layer needs.\n\n![MobileNetV2 Figure 1 showing a spiral mapped to different dimensions before ReLU](/content/papers/assets/fa9960be3fd190fa1e6d1ebd0b00627a733a63b5276603aa9a880b62e851fc25.jpg)\n\n*Paper Figure 1: a two-dimensional spiral is embedded into 2, 3, 5, 15, or 30 dimensions, passed through ReLU, and mapped back to two dimensions. The low-dimensional examples collapse parts of the curve, while higher-dimensional ones express more complex shapes. The figure offers geometric intuition, not an invertibility guarantee for arbitrary data and projections.*\n\nLook for the distinct points that ReLU folds together, not a rule that more dimensions are always lossless. The authors place nonlinearities in the expanded channels and leave the **final 1×1 projection into the narrow bottleneck linear**. A linear projection can still discard information, but it does not additionally clip many values to the same ReLU6 output.\n\n### Where Does the Residual Shortcut Connect?\n\n![Reference ResNet bottleneck with a 256-channel shortcut and a 64-channel middle](/content/papers/assets/a582ed00a15da709c6839e653f84f694e1170cc83d0846fa897c62d1819e986c.jpg)\n\n*Imported ResNet bottleneck sketch: the shortcut spans a 256→64→256 main path whose 3×3 layer is a standard convolution. This is a reference residual structure, not a MobileNetV2 unit.*\n\nA conventional bottleneck first narrows channels with a 1×1 convolution, applies a 3×3 in the narrow space, and restores channels with another 1×1. The shortcut joins the wider ends. MobileNetV2 reverses the width pattern: input and output are narrow, the middle expands before its depthwise 3×3, and the shortcut joins the narrow ends. Addition is possible only at stride 1 with equal input and output channels; downsampling or a channel change prevents a direct shortcut.\n\n## Solving the Problem\n\n### Inverted Residual and Linear Bottleneck\n\nThe unit is called an **inverted residual with linear bottleneck**. Trace a 14×14×64 input. A 1×1 convolution with expansion factor $t=6$ first creates **384** channels. Depthwise 3×3 then processes spatial information separately in each expanded channel. A final 1×1 projects back to 64 channels. The first two operations have BN and ReLU6; the final one has BN but **no ReLU6**. If stride is 1 and output remains 14×14×64, add the original input.\n\n![MobileNetV2 paper Figure 4 comparing V1 with stride-1 and stride-2 V2 blocks](/content/papers/assets/e6bbfb346bb449f83897d76b69c3711d2e9937d40320a7aab0f3843653a688c0.jpg)\n\n*Paper Figure 4 crop: the middle V2 stride-1 block has a shortcut between narrow ends; the right stride-2 block has no direct additive shortcut. Both end in a linear 1×1 projection. The left block shows MobileNetV1.*\n\nThe first block with $t=1$ can omit the expansion layer. A stride-2 depthwise operation shrinks spatial size, so it has no equal-size shortcut. Paper Figure 3 compares shortcuts between narrow ends with classical residual designs; the imported diagram above shows the operation order.\n\n### Why Expand the Bottleneck?\n\nAppendix A abstracts a vector transformation as $A\\operatorname{ReLU}(Bx)$. Here $x\\in\\mathbb{R}^n$; $B\\in\\mathbb{R}^{m\\times n}$ maps $n$ dimensions to $m$; ReLU acts elementwise; and $A\\in\\mathbb{R}^{n\\times m}$ projects back to $n$. The $m$ in this model is the **intermediate width**, not necessarily the network's output channel count.\n\nWith $m\\leq n$, compression followed by ReLU makes it easier for distinct inputs to collapse together. With $m>n$, extra intermediate channels offer more ways to preserve distinctions and more room for nonlinear expression. But $m>n$ alone does not make arbitrary $A\\operatorname{ReLU}(Bx)$ invertible: rank, active channels, and the data distribution matter. Expansion lowers the risk of information collapse; the linear bottleneck avoids another clipping operation after projection.\n\n### From Block to Network\n\n![MobileNetV2 Table 2 listing input size, expansion, output channels, repeats, and stride](/content/papers/assets/9912ae0c832611f178c3354b7ca40a50fb1ad77813e6742739e7976b23521bc4.jpg)\n\n*Paper Table 2: $t$ is expansion factor, $c$ output channels, $n$ the row's repeat count, and $s$ the stride of its first block; later repeats use stride 1. A 224²×3 input eventually reaches 1280 channels, global average pooling, and classification.*\n\nThe initial standard 3×3 convolution changes 224×224×3 to 112×112×32. The first bottleneck row is $t=1,c=16,n=1,s=1$; the next is $t=6,c=24,n=2,s=2$, whose first block downsamples to 56×56 and whose second stays at that size. Later rows produce 32, 64, 96, 160, and 320 channels before the final 1×1, pooling, and classifier. Section 4 calls these 19 bottleneck layers, but the Table 2 repeat counts $1+2+3+4+3+3+1$ sum to **17**. The code below follows the table and instantiates 17 units; the two counts should not be treated as identical.\n\nFirst implement one unit so the linear projection and shortcut condition are visible:\n\n```python\nimport torch.nn as nn\n\n\nclass InvertedResidual(nn.Module):\n    def __init__(self, inp, oup, stride, expand_ratio):\n        super().__init__()\n        if stride not in (1, 2):\n            raise ValueError(\"stride must be 1 or 2\")\n        hidden_dim = int(inp * expand_ratio)\n        self.is_shortcut = stride == 1 and inp == oup\n        layers = []\n        if expand_ratio != 1:\n            layers.extend([\n                nn.Conv2d(inp, hidden_dim, 1, bias=False),\n                nn.BatchNorm2d(hidden_dim),\n                nn.ReLU6(),\n            ])\n        layers.extend([\n            # Depthwise convolution in the expanded space.\n            nn.Conv2d(hidden_dim, hidden_dim, 3, stride, 1,\n                      groups=hidden_dim, bias=False),\n            nn.BatchNorm2d(hidden_dim),\n            nn.ReLU6(),\n            # Linear projection: deliberately no activation after BN.\n            nn.Conv2d(hidden_dim, oup, 1, bias=False),\n            nn.BatchNorm2d(oup),\n        ])\n        self.conv = nn.Sequential(*layers)\n\n    def forward(self, x):\n        out = self.conv(x)\n        return x + out if self.is_shortcut else out\n```\n\nNow connect the units according to Table 2. This is a **feature extractor**: it omits pooling and the 1000-class head. Channel counts use simple integer rounding rather than the multiples-of-eight rounding common in deployment implementations, so weights from those implementations may not load. The input size is not hard-coded here:\n\n```python\nimport torch.nn as nn\n\nclass MobileNetV2(nn.Module):\n\n    def __init__(self, width_mult=1.):\n        super(MobileNetV2, self).__init__()\n\n        if width_mult <= 0:\n            raise ValueError(\"width_mult must be positive\")\n\n        # setting of inverted residual blocks\n        self.settings = [\n            # t, c, n, s\n            [1, 16, 1, 1],\n            [6, 24, 2, 2],\n            [6, 32, 3, 2],\n            [6, 64, 4, 2],\n            [6, 96, 3, 1],\n            [6, 160, 3, 2],\n            [6, 320, 1, 1],\n        ]\n\n        # building first layer\n        input_channel = max(1, int(32 * width_mult))\n        self.first_layer = nn.Sequential(\n            nn.Conv2d(3, input_channel, 3, 2, 1, bias=False),\n            nn.BatchNorm2d(input_channel),\n            nn.ReLU6()\n        )\n\n        # building inverted residual blocks\n        layers = []\n        for t, c, n, s in self.settings:\n            output_channel = max(1, int(c * width_mult))\n            for i in range(n):\n                layers.append(\n                    InvertedResidual(\n                        input_channel,\n                        output_channel,\n                        stride=s if i == 0 else 1,\n                        expand_ratio=t\n                    )\n                )\n                input_channel = output_channel\n        self.layers = nn.Sequential(*layers)\n\n        # building last several layers\n        last_channel = int(1280 * width_mult) if width_mult > 1.0 else 1280\n        self.last_layer = nn.Sequential(\n            nn.Conv2d(input_channel, last_channel, 1, 1, 0, bias=False),\n            nn.BatchNorm2d(last_channel),\n            nn.ReLU6()\n        )\n\n    def forward(self, x):\n        x = self.first_layer(x)\n        x = self.layers(x)\n        x = self.last_layer(x)\n        return x\n```\n\n\n> [!TIP]\n> \n> Convolution bias is set to False because the following Batch Normalization already has a learned offset. The examples show operation order, not the paper's training recipe, and do not implement the low-memory schedule of §5.1. For a width multiplier below 1, the paper does not narrow the final 1280-channel convolution.\n\n\n## Discussion\n\n### ImageNet Classification and Phone Latency\n\n![MobileNetV2 Table 4 comparing ImageNet top-1, parameters, multiply-adds, and Pixel 1 CPU latency](/content/papers/assets/e815ff29a16e2d442671792e9bb137ca24e052e380d8c20ba3c737eb30b4db8c.jpg)\n\n*Paper Table 4: arithmetic cost is in MAdds; CPU milliseconds are measured on one large Google Pixel 1 core with TF-Lite. The CPU entries for both ShuffleNet models are blank.*\n\nIn this table, baseline MobileNetV2 has **72.0% top-1, 3.4M parameters, 300M MAdds, and 75 ms**. MobileNetV1 has **70.6%, 4.2M, 575M, and 113 ms**. V2 is **1.4 percentage points** more accurate, uses about **48%** fewer multiply-adds, and has about **34%** lower latency in the same phone column. The MobileNetV1 paper elsewhere reports 569M; this comparison uses the **575M** printed in MobileNetV2 Table 4.\n\nAround 300M MAdds, ShuffleNet 1.5× has **71.5%/292M**, while MobileNetV2 has **72.0%/300M**: V2 gains **0.5 point** but costs **8M** more MAdds, and no ShuffleNet CPU number is reported. Around 600M, MobileNetV2 1.4× has **74.7%/585M/143 ms** against NASNet-A's **74.0%/564M/183 ms**. V2 gains **0.7 point** and has slightly more MAdds and parameters, with about **22%** lower latency on this phone.\n\n### Other Tasks and Limits\n\nThe paper also uses V2 as a feature extractor for detection and segmentation. In COCO test-dev Table 6, V2+SSDLite has **22.1 mAP/0.8B MAdds/200 ms** against V1+SSDLite's **22.2/1.3B/270 ms**. V2 does **not** have higher mAP in these rows, though it uses fewer operations and is faster on the Pixel 1. In PASCAL VOC Table 7, the V2 variant using the penultimate feature map, no ASPP, output stride 16, and no multiscale/flipped testing reaches **75.32% mIoU/2.75B MAdds**. These configurations are separate from the 300M-MAdd classification model.\n\nPaper Figure 6 separately ablates bottleneck nonlinearity and shortcut placement. The authors report benefits from linear bottlenecks and narrow-end shortcuts. The memory savings also depend on the computation schedule in §5.1, so peak memory requires measurement with that schedule.\n\n## Conclusion\n\nMobileNetV2 keeps nonlinearities in expanded intermediate channels, leaves the final narrow projection linear, and passes features across narrow-end shortcuts where shapes permit. In the paper's ImageNet and Pixel 1 settings, it improves accuracy while reducing multiply-adds and latency relative to V1. Downstream tasks require their own metrics and configurations.\n\nFor deployment, fix the width multiplier, input size, task head, and operator library first, then measure latency and memory on the target hardware. The paper gives a useful block design; realized gains depend on the complete model and runtime. Future work can keep exploring accuracy and generalization within these resource limits.\n","imageSizes":{"/content/papers/assets/fa9960be3fd190fa1e6d1ebd0b00627a733a63b5276603aa9a880b62e851fc25.jpg":{"width":1588,"height":268},"/content/papers/assets/a582ed00a15da709c6839e653f84f694e1170cc83d0846fa897c62d1819e986c.jpg":{"width":730,"height":574},"/content/papers/assets/e6bbfb346bb449f83897d76b69c3711d2e9937d40320a7aab0f3843653a688c0.jpg":{"width":2332,"height":1324},"/content/papers/assets/9912ae0c832611f178c3354b7ca40a50fb1ad77813e6742739e7976b23521bc4.jpg":{"width":1032,"height":784},"/content/papers/assets/e815ff29a16e2d442671792e9bb137ca24e052e380d8c20ba3c737eb30b4db8c.jpg":{"width":1156,"height":496}}}
