Skip to content
fn

mobilenet_cls

→MobileNetForImageClassification4.2M
mobilenet_cls(pretrained: bool | str = False, weights: MobileNetWeights | None = None, overrides: object = {})

MobileNet-v1 image classifier at width multiplier α=1.0\alpha = 1.0.

Builds a MobileNetForImageClassification with the canonical paper topology (13 depthwise+pointwise blocks) followed by global average pooling and a linear projection to config.num_classes (default 1000 for ImageNet-1k). Approximately 4.2M parameters and 70.6% ImageNet-1k top-1 in Howard et al., 2017 (Table 6).

Model Size

Parameters

pretrainedbool or str= False
Pretrained-weight selector. False → random init; True → the DEFAULT tag (MobileNetWeights.RA4_E3600_R224_IN1K); a tag string → that specific checkpoint. Mutually exclusive with weights (which wins if both are given).
weights(MobileNetWeights, optional, keyword - only)= None
Explicit weights enum member. Takes precedence over pretrained.
**overridesobject= {}
Keyword overrides forwarded into MobileNetConfig (typically num_classes to retarget the classifier).

Returns

MobileNetForImageClassification

Classifier with the MobileNet-v1 (α=1.0\alpha = 1.0) configuration applied (or with overrides merged on top of it).

Notes

See Howard et al., "MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications", arXiv:1704.04861, 2017, Table 6. Pretrained weights are converted from timm's mobilenetv1_100.ra4_e3600_r224_in1k (75.4% top-1 at 224x224 under the RA4 recipe) and hosted under lucid-dl/mobilenet-v1.

Examples

>>> import lucid
>>> from lucid.models.vision.mobilenet import mobilenet_cls
>>> model = mobilenet_cls(num_classes=10)
>>> x = lucid.randn(2, 3, 224, 224)
>>> out = model(x)
>>> out.logits.shape
(2, 10)

Used by 1