Skip to content
fn

xception_cls

→XceptionForImageClassification22.9M
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 (p=0.5p = 0.5) and a linear projection to config.num_classes (default 1000 for ImageNet-1k). 22,855,952 parameters, exactly the count Chollet reports for Xception, and 79.0% ImageNet-1k top-1 accuracy at 299×299 — outperforming Inception-v3 at the same parameter budget.

Model Size

Parameters

pretrainedbool or str= False
Pretrained-weight selector. False → 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).
weights(XceptionWeights, optional, keyword - only)= None
Explicit weights enum member, e.g. XceptionWeights.TF_IN1K. Takes precedence over pretrained.
**overridesobject= {}
Keyword overrides forwarded into XceptionConfig (typically num_classes to retarget the classifier).

Returns

XceptionForImageClassification

Classifier 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). 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)

Used by 1