Skip to content
class

MobileNetV3

extendsPretrainedModelBackboneMixin
MobileNetV3(config: MobileNetV3Config)

MobileNet v3 feature-extracting backbone (no classification head).

Implements the NAS-designed topology from Howard et al., "Searching for MobileNetV3", ICCV 2019 (arXiv:1905.02244). The architecture combines MobileNet-v2's inverted-residual block with three new ingredients selected by a platform-aware architecture search: a lightweight squeeze-and-excitation module in selected blocks, the hard-swish activation (x⋅ReLU6(x+3)/6x \cdot \mathrm{ReLU6}(x+3) / 6) in the deeper half of the network, and a redesigned head that moves the expensive 1×1 expansion after the global average pool.

Two hand-tuned variants are exposed: "large" (15 blocks, targeting higher-accuracy mobile deployments) and "small" (11 blocks, targeting tight latency budgets). Channel counts scale uniformly with config.width_mult.

Parameters

Frozen architecture spec. Use the factory functions (mobilenet_v3_large, mobilenet_v3_small) for paper-cited variants.

Attributes

Stored copy of the config that built this model.
Stem + 11 (Small) or 15 (Large) inverted-residual SE blocks
  • 1×1 penultimate expansion. Channel counts scale with config.width_mult.
Global average pool collapsing the final feature map to (B, C, 1, 1).
feature_infolist[FeatureInfo]
Per-stage descriptor (channels + reduction factor) exposed via BackboneMixin for downstream FPN / decoder modules.

Notes

The hard-swish activation,

h-swish(x)=x⋅ReLU6(x+3)6,\mathrm{h\text{-}swish}(x) = x \cdot \frac{\mathrm{ReLU6}(x + 3)}{6},

closely approximates swish/SiLU using only piecewise-linear primitives, making it dramatically cheaper to evaluate on mobile-friendly fixed-point hardware. Combined with the redesigned tail (moving the 1×1 expansion to operate on a single spatial location after global average pooling), the overall network achieves 3.2%3.2\% higher ImageNet top-1 accuracy than MobileNet-v2 at 20%20\% lower latency on a Pixel-1 CPU.

Examples

Build a MobileNet-v3-Large backbone and run a forward pass:
>>> import lucid
>>> from lucid.models.vision.mobilenet_v3 import mobilenet_v3_large
>>> backbone = mobilenet_v3_large()
>>> x = lucid.randn(2, 3, 224, 224)
>>> out = backbone(x)
>>> out.last_hidden_state.shape
(2, 960, 7, 7)

Used by 2

Constructors

1
dunder

__init__

→None
__init__(config: MobileNetV3Config)

Instance methods

2
fn

forward_features

→Tensor
forward_features(x: Tensor)

Run the backbone's feature-extraction pass.

Parameters

Input image batch, shape (B, C, H, W).

Returns

Tensor

Feature map at the deepest stage. Concrete subclasses may additionally stash earlier stages on the instance so multi-stage consumers can fetch them.

Examples

The map returned is the one feature_info lists last, so a
neck can size itself from that entry without running the model.
>>> import lucid
>>> from lucid.models import create_model
>>> backbone = create_model("resnet_18").eval()
>>> last = backbone.feature_info[-1]
>>> last.num_channels, last.reduction
(512, 32)
>>> backbone.forward_features(lucid.randn((1, 3, 64, 96))).shape
(1, 512, 2, 3)
Each side is divided by the advertised reduction on its own, so
a non-square input keeps its aspect ratio.