Skip to content
class

MobileNetV3ForImageClassification

extendsImageClassificationModelClassificationHeadMixin
MobileNetV3ForImageClassification(config: MobileNetV3Config)

MobileNet v3 image classifier with the redesigned inverted head.

Combines a MobileNetV3 feature stack with the paper's redesigned classification head, which is the central efficiency innovation of v3. Instead of the conventional GAP → Linear head, v3 places a 1×11 \times 1 convolution after the global average pool — when the spatial map has already collapsed to 1 × 1 — saving roughly 10%10\% of total latency compared to v2's pre-pool expansion. The full head is

AvgPool⁡→Conv⁡1×1→h-swish→Flatten⁡→Dropout⁡→Linear⁡.\operatorname{AvgPool} \to \operatorname{Conv}_{1\times1} \to \mathrm{h\text{-}swish} \to \operatorname{Flatten} \to \operatorname{Dropout} \to \operatorname{Linear}.

Parameters

Architecture spec. Use the *_cls factory functions (mobilenet_v3_large_cls, mobilenet_v3_small_cls) for paper-cited variants.

Attributes

Stored copy of the config that built this model.
Same NAS-designed feature stack as on MobileNetV3.
classifiernn.Sequential
The redesigned head described above, projecting from the penultimate channel count (960 for Large, 576 for Small) to config.num_classes via a 1280-ch (Large) or 1024-ch (Small) intermediate width.

Notes

When labels are supplied to forward, a categorical cross-entropy loss is computed against the logits and returned alongside them.

Examples

Run inference on a batch of 224×224 RGB images:
>>> import lucid
>>> from lucid.models.vision.mobilenet_v3 import mobilenet_v3_large_cls
>>> model = mobilenet_v3_large_cls()
>>> x = lucid.randn(4, 3, 224, 224)
>>> out = model(x)
>>> out.logits.shape
(4, 1000)
Build the smaller variant for latency-critical deployment:
>>> from lucid.models.vision.mobilenet_v3 import mobilenet_v3_small_cls
>>> small = mobilenet_v3_small_cls(num_classes=10)
>>> small.config.variant
'small'

Used by 2

Constructors

1
dunder

__init__

→None
__init__(config: MobileNetV3Config)

Instance methods

1