class
MobileNetV3ForImageClassification
extends
PretrainedModelClassificationHeadMixinMobileNetV3ForImageClassification(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
convolution after the global average pool — when the spatial
map has already collapsed to 1 × 1 — saving roughly
of total latency compared to v2's pre-pool
expansion. The full head is
Parameters
configMobileNetV3ConfigArchitecture spec. Use the
*_cls factory functions
(mobilenet_v3_large_cls, mobilenet_v3_small_cls)
for paper-cited variants.Attributes
configMobileNetV3ConfigStored copy of the config that built this model.
featuresnn.SequentialSame NAS-designed feature stack as on
MobileNetV3.classifiernn.SequentialThe 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
1Instance methods
1forward(x: Tensor, labels: Tensor | None = None)