resnet_50_cls(pretrained: bool | str = False, weights: ResNet50Weights | None = None, overrides: object = {})ResNet-50 image classifier (backbone + GAP + linear head).
Builds a ResNetForImageClassification with the paper-cited
ResNet-50 topology: _Bottleneck blocks stacked
[3, 4, 6, 3] over four stages, followed by global average
pooling and a linear projection to config.num_classes.
Approximately 25.6M parameters and 76.13% ImageNet-1k top-1 in
He et al., 2015 (Table 4) — the canonical default for ImageNet
classification benchmarks.
Model Size
Parameters
pretrainedbool or str= FalseFalse → random init; True
→ the DEFAULT tag (ResNet50Weights.IMAGENET1K_V1);
a tag string → that specific checkpoint. Mutually exclusive
with weights (which wins if both are given).pretrained.**overridesobject= {}ResNetConfig. Use
num_classes=N to retarget the head (e.g. num_classes=10
for CIFAR-10 fine-tuning) and dropout=p to inject
regularisation before the final linear layer.Returns
ResNetForImageClassificationClassifier with the ResNet-50 configuration applied (or with
overrides merged on top of it), optionally initialised from
pretrained weights.
Notes
See He et al., "Deep Residual Learning for Image Recognition",
CVPR 2016 (arXiv:1512.03385), Table 1. Final pre-classifier
feature has 2048 channels (hidden_sizes[3] * expansion).
Pretrained weights are converted from torchvision's
ResNet50_Weights and hosted on the Hugging Face Hub under
lucid-dl/resnet-50.
Examples
Run a forward pass without labels:
>>> import lucid
>>> from lucid.models.vision.resnet import resnet_50_cls
>>> model = resnet_50_cls()
>>> x = lucid.randn(4, 3, 224, 224)
>>> out = model(x)
>>> out.logits.shape
(4, 1000)
Retarget to CIFAR-10 and add dropout:
>>> model = resnet_50_cls(num_classes=10, dropout=0.1)
>>> model.config.num_classes
10