vit_base_16_cls(pretrained: bool | str = False, weights: ViTBase16Weights | None = None, overrides: object = {})ViT-Base/16 image classifier (Dosovitskiy et al., 2020).
Combines the vit_base_16 backbone with a single
nn.Linear classification head on the CLS token. Default
output is num_classes=1000 (ImageNet-1k); override via
num_classes=.... Approximately 86M parameters for the
1000-class head.
Model Size
Parameters
pretrainedbool or str= FalsePretrained-weight selector.
False → random init; True
→ the DEFAULT tag (ViTBase16Weights.IMAGENET1K_V1); a
tag string → that specific checkpoint. Mutually exclusive with
weights (which wins if both are given).Explicit weights enum member. Takes precedence over
pretrained.**overridesobject= {}Keyword overrides on top of the canonical ViT-Base/16 config.
Commonly used:
num_classes to switch label space,
image_size to fine-tune at higher resolution.Returns
ViTForImageClassificationClassifier returning ImageClassificationOutput whose
logits has shape (B, num_classes).
Notes
Standard ImageNet recipe: backbone returns the CLS token after the
final LayerNorm, head applies a single affine map to produce class
logits. Pretrained weights are converted from torchvision's
ViT_B_16_Weights.IMAGENET1K_V1 (81.072% top-1) and hosted under
lucid-dl/vit-base-16. See
arXiv:2010.11929.
Examples
>>> import lucid
>>> from lucid.models.vision.vit import vit_base_16_cls
>>> model = vit_base_16_cls(num_classes=1000)
>>> x = lucid.randn(1, 3, 224, 224)
>>> out = model(x)
>>> out.logits.shape
(1, 1000)