Skip to content
fn

inception_v4_cls

→InceptionV4ForImageClassification42.7M
inception_v4_cls(pretrained: bool | str = False, weights: InceptionV4Weights | None = None, overrides: object = {})

Inception-v4 image classifier (trunk + GAP + dropout + linear).

Builds an InceptionV4ForImageClassification with the paper's topology and head — global average pool, dropout with keep probability 0.8, and a lucid.nn.Linear layer producing config.num_classes logits. 42.7 M parameters, matching the released TF-Slim ImageNet checkpoint.

Model Size

Parameters

pretrainedbool or str= False
Pretrained-weight selector. False → random init; True → the DEFAULT tag (InceptionV4Weights.TF_IN1K); a tag string (e.g. "TF_IN1K") → that specific checkpoint. Mutually exclusive with weights (which wins if both are given).
weights(InceptionV4Weights, optional, keyword - only)= None
Explicit weights enum member, e.g. InceptionV4Weights.TF_IN1K. Takes precedence over pretrained.
**overridesobject= {}
Keyword overrides forwarded into InceptionV4Config. Common picks: num_classes=N to retarget the head, dropout=p to change the head regularisation. Overriding num_classes away from the checkpoint's 1000 makes pretrained loading fail the strict key/shape check — load with the matching head, then call reset_classifier.

Returns

InceptionV4ForImageClassification

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

Notes

See Szegedy et al., "Inception-v4, Inception-ResNet and the Impact of Residual Connections on Learning", AAAI 2017. Single-crop ImageNet validation error reported in Table 2: 20.0% top-1 / 5.0% top-5. The head is named last_linear so the TF-Slim checkpoint's keys load unchanged.

Pretrained weights are converted from timm's inception_v4.tf_in1k — the TensorFlow-Slim ImageNet-1k checkpoint — and hosted on the Hugging Face Hub under lucid-dl/inception-v4. timm reports 80.144% top-1 / 94.982% top-5 for it at 299x299 with the preset that InceptionV4Weights.TF_IN1K.transforms reproduces (299 crop, 341 resize, bicubic, (0.5, 0.5, 0.5) mean/std — the TF-Slim [−1,1][-1, 1] scaling, not the ImageNet statistics).

Examples

>>> import lucid
>>> from lucid.models.vision.inception_v4 import inception_v4_cls
>>> model = inception_v4_cls(num_classes=10).eval()
>>> out = model(lucid.randn(2, 3, 299, 299))
>>> out.logits.shape
(2, 10)
Load ImageNet-pretrained weights:
>>> model = inception_v4_cls(pretrained=True)
>>> from lucid.models.weights import InceptionV4Weights
>>> model = inception_v4_cls(weights=InceptionV4Weights.TF_IN1K)

Used by 1