alexnet_cls(pretrained: bool | str = False, weights: AlexNetWeights | None = None, overrides: object = {})AlexNet image classifier (backbone + FC6 + FC7 + linear head).
Builds an AlexNetForImageClassification with the
Krizhevsky 2014 single-stream OWT topology: the five-block conv
trunk followed by FC6 (9216 → 4096), FC7 (4096 → 4096), and a
final linear projection to config.num_classes (default 1000
for ImageNet-1k). Approximately 61.1 M parameters total,
dominated by the two 4096-dim FC layers (≈54.5 M).
lucid.nn.Dropout with p=config.dropout (default 0.5)
is applied after both hidden activations.
Model Size
Parameters
pretrainedbool or str= FalseFalse → random init; True
→ the DEFAULT tag (AlexNetWeights.IMAGENET1K_V1);
a tag string (e.g. "IMAGENET1K_V1") → that specific
checkpoint. Mutually exclusive with weights (which wins
if both are given).AlexNetWeights.IMAGENET1K_V1. Takes precedence over
pretrained.**overridesobject= {}AlexNetConfig. Use
num_classes=N to retarget the classifier (e.g.
num_classes=10 for CIFAR-10 fine-tuning) and dropout=p
to adjust the regularisation strength. Note: overriding
num_classes away from the checkpoint's class count makes
pretrained loading fail the strict key/shape check.Returns
AlexNetForImageClassificationClassifier with the AlexNet configuration applied (or with
overrides merged on top of it), optionally initialised
from pretrained weights.
Notes
The two lucid.nn.Dropout layers were a key empirical
contribution of the original NIPS 2012 paper: setting half of each
4096-dim activation to zero during training was the principal
technique that prevented overfitting of a 60 M-parameter network
on 1.2 M images. Pretrained weights are converted from
torchvision's AlexNet_Weights.IMAGENET1K_V1 and hosted on the
Hugging Face Hub under lucid-dl/alexnet.
Examples
Run a forward pass without labels:
>>> import lucid
>>> from lucid.models.vision.alexnet import alexnet_cls
>>> model = alexnet_cls()
>>> x = lucid.randn(2, 3, 224, 224)
>>> out = model(x)
>>> out.logits.shape
(2, 1000)
Load ImageNet-pretrained weights:
>>> model = alexnet_cls(pretrained=True) # DEFAULT tag
>>> from lucid.models.vision.alexnet import AlexNetWeights
>>> model = alexnet_cls(weights=AlexNetWeights.IMAGENET1K_V1)