Skip to content
module

MobileNet-v4

18 members
lucid.models.vision.mobilenet_v4

MobileNet v4 family — Qin et al., 2024.

Image Classification
Paper

Qin, Danfeng, et al. "MobileNetV4: Universal Models for the Mobile Ecosystem." Computer Vision – ECCV 2024, Lecture Notes in Computer Science, vol. 15098, Springer, 2024.

Overview

MobileNet-v4 is built around a single searchable block, the Universal Inverted Bottleneck (UIB). It extends the inverted bottleneck of MobileNet-v2 with two optional depthwise convolutions: one before the 1×11 \times 1 expansion and one between the expansion and the 1×11 \times 1 projection,

UIB(x)=x+γ⊙P(Dmid(E(Dstart(x)))),\mathrm{UIB}(x) = x + \gamma \odot P\bigl(D_{\mathrm{mid}}(E(D_{\mathrm{start}}(x)))\bigr),

where EE is the pointwise expansion, PP the linear pointwise projection, and each DD is either a depthwise convolution or the identity. The four on/off combinations recover four familiar blocks: the classic inverted bottleneck (IB, middle depthwise only), a ConvNeXt-like block (start depthwise only, a cheap large-kernel spatial mix before the expansion), a transformer FFN (neither — two pointwise layers), and the new ExtraDW block (both), which deepens the network and widens its receptive field at almost no cost. Because the expansion and projection are shared by all four instantiations, a NAS super-network over UIB shares more than 95% of its parameters, and the search simply decides which depthwise layers to keep at each position. The stems use a fused inverted bottleneck — a dense 3×33 \times 3 convolution into a 1×11 \times 1 projection — which is faster than a depthwise pair at high resolution.

The hybrid variants interleave UIB blocks with Mobile MQA, a multi-query attention block tuned for accelerators: every query head shares a single key and value head, which raises operational intensity when the token count is small relative to the channel width, and the keys and values can be spatially reduced by a stride-2 3×33 \times 3 depthwise convolution,

MQA(X)=Concatj=1h ⁣[softmax ⁣((XWjQ) (SR(X)WK)⊤dk)SR(X)WV]WO.\mathrm{MQA}(X) = \mathrm{Concat}_{j=1}^{h}\!\left[ \mathrm{softmax}\!\left( \frac{(X W^{Q}_{j})\,(\mathrm{SR}(X) W^{K})^{\top}} {\sqrt{d_k}}\right) \mathrm{SR}(X) W^{V}\right] W^{O}.

Sharing keys and values cuts attention latency by more than 39% on mobile accelerators relative to multi-head attention at a negligible accuracy cost. Residual branches of the hybrids are scaled by a learnable per-channel layer scale γ\gamma initialised at 10−510^{-5}.

Five models come out of the search: Conv-Small, Conv-Medium and Conv-Large, built only from UIB and fused-IB blocks, and Hybrid-Medium and Hybrid-Large, which add Mobile MQA to the last two stages. Every model ends with the MobileNet-v3 style head that moves the widest 1×11 \times 1 layer after global pooling. They are mostly Pareto-optimal across mobile CPUs, DSPs, GPUs, the Apple Neural Engine and the Pixel EdgeTPU at once, ranging from 73.8% ImageNet-1k top-1 at 0.2 GMACs (Conv-Small) to 83.4% (Hybrid-Large).

Classes

Functions

Weights