Skip to content
fn

resnext_50_32x4d_cls

→ResNeXtForImageClassification
resnext_50_32x4d_cls(pretrained: bool | str = False, weights: ResNeXt50_32x4dWeights | None = None, overrides: object = {})

ResNeXt-50 (32x4d) image classifier (backbone + GAP + linear head).

Builds a ResNeXtForImageClassification with the paper-cited ResNeXt-50 (32x4d) topology and a lucid.nn.Linear classifier projecting 2048 → config.num_classes. Approximately 25.0 M parameters; the distributed IMAGENET1K_V2 checkpoint reaches 81.198% ImageNet-1k top-1 with the improved training recipe.

Model Size

Parameters

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

Returns

ResNeXtForImageClassification

Classifier with the ResNeXt-50 (32x4d) configuration applied (or with overrides merged on top of it), optionally initialised from pretrained weights.

Notes

Pretrained weights are converted from reference_vision's ResNeXt50_32X4D_Weights.IMAGENET1K_V2 and hosted on the Hugging Face Hub under lucid-dl/resnext-50-32x4d. The V2 preset uses a 232 resize ahead of the 224 center crop.

Examples

>>> import lucid
>>> from lucid.models.vision.resnext import resnext_50_32x4d_cls
>>> model = resnext_50_32x4d_cls(num_classes=100)
>>> x = lucid.randn(2, 3, 224, 224)
>>> out = model(x)
>>> out.logits.shape
(2, 100)
Load ImageNet-pretrained weights:
>>> model = resnext_50_32x4d_cls(pretrained=True)
>>> from lucid.models.vision.resnext import ResNeXt50_32x4dWeights
>>> model = resnext_50_32x4d_cls(weights=ResNeXt50_32x4dWeights.IMAGENET1K_V2)

Used by 1