xception_cls(pretrained: bool | str = False, weights: XceptionWeights | None = None, overrides: object = {})Xception image classifier (backbone + dropout + linear head).
Builds an XceptionForImageClassification with the
canonical Xception backbone (Chollet, 2017) followed by
dropout () and a linear projection to
config.num_classes (default 1000 for ImageNet-1k).
Approximately 22.9M parameters and 79.0% ImageNet-1k top-1
accuracy at 299×299 (paper, Table 5) — outperforming
Inception-v3 at the same parameter budget.
Model Size
Parameters
pretrainedbool or str= FalseFalse → random init; True
→ the DEFAULT tag (XceptionWeights.TF_IN1K); a tag
string (e.g. "TF_IN1K") → that specific checkpoint.
Mutually exclusive with weights (which wins if both are
given).XceptionWeights.TF_IN1K. Takes precedence over
pretrained.**overridesobject= {}XceptionConfig
(typically num_classes to retarget the classifier).Returns
XceptionForImageClassificationClassifier with the canonical Xception configuration
applied (or with overrides merged on top of it),
optionally initialised from pretrained weights.
Notes
See Chollet, "Xception: Deep Learning with Depthwise Separable
Convolutions", CVPR 2017 (arXiv:1610.02357), Table 5. Pretrained
weights are converted from timm's legacy_xception.tf_in1k and
hosted on the Hugging Face Hub under lucid-dl/xception. The
eval preset is 299 crop / 333 resize / bicubic / mean=std=0.5 (not
ImageNet stats).
Examples
>>> import lucid
>>> from lucid.models.vision.xception import xception_cls
>>> model = xception_cls(num_classes=10)
>>> x = lucid.randn(2, 3, 299, 299)
>>> out = model(x)
>>> out.logits.shape
(2, 10)
Load ImageNet-pretrained weights:
>>> model = xception_cls(pretrained=True) # DEFAULT tag
>>> from lucid.models.vision.xception import XceptionWeights
>>> model = xception_cls(weights=XceptionWeights.TF_IN1K)