Skip to content
fn

efficientnet_b0_cls

→EfficientNetForImageClassification
efficientnet_b0_cls(pretrained: bool | str = False, weights: EfficientNetB0Weights | None = None, overrides: object = {})

EfficientNet-B0 image classifier (backbone + GAP + linear head).

Builds an EfficientNetForImageClassification with the NAS-designed B0 topology followed by global average pooling, dropout (p=0.2p = 0.2), and a linear projection to config.num_classes (default 1000 for ImageNet-1k). Approximately 5.3M parameters and 77.1% ImageNet-1k top-1 accuracy at 224×224 (Tan & Le, 2019, Table 2).

Model Size

Parameters

pretrainedbool or str= False
Pretrained-weight selector. False → random init; True → the DEFAULT tag (EfficientNetB0Weights.IMAGENET1K_V1); a tag string (e.g. "IMAGENET1K_V1") → that specific checkpoint. Mutually exclusive with weights (which wins if both given).
weights(EfficientNetB0Weights, optional, keyword - only)= None
Explicit weights enum member, e.g. EfficientNetB0Weights.IMAGENET1K_V1. Takes precedence over pretrained.
**overridesobject= {}
Keyword overrides forwarded into EfficientNetConfig (typically num_classes to retarget the classifier). Overriding num_classes away from the checkpoint's class count makes pretrained loading fail the strict key/shape check.

Returns

EfficientNetForImageClassification

Classifier with the B0 configuration applied (or with overrides merged on top of it), optionally initialised from pretrained weights.

Notes

See Tan & Le, "EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks", ICML 2019 (arXiv:1905.11946), Table 2. Pretrained weights are converted from the reference-framework EfficientNet_B0_Weights and hosted on the Hugging Face Hub under lucid-dl/efficientnet-b0.

Examples

>>> import lucid
>>> from lucid.models.vision.efficientnet import efficientnet_b0_cls
>>> model = efficientnet_b0_cls(num_classes=10)
>>> x = lucid.randn(2, 3, 224, 224)
>>> out = model(x)
>>> out.logits.shape
(2, 10)
Load ImageNet-pretrained weights:
>>> model = efficientnet_b0_cls(pretrained=True)            # DEFAULT tag

Used by 1