Skip to content
class

XceptionForImageClassification

extendsImageClassificationModelClassificationHeadMixin_XceptionBody
XceptionForImageClassification(config: XceptionConfig)

Xception with dropout + linear classification head.

Combines an Xception backbone with a dropout layer (probability config.dropout, default 0.5 per the paper) and a linear projection to config.num_classes logits. When labels are supplied to forward, a cross-entropy loss is computed and returned alongside the logits inside an XceptionOutput dataclass.

Parameters

Architecture spec. Use the xception_cls factory for the paper-cited configuration.

Attributes

Stored copy of the config that built this model.
conv1, conv2, bn1, bn2, block1, …, block12, conv3, conv4, bn3, bn4, avgpool
Same backbone components as on Xception; see that class for shape semantics.
classifiernn.Module
Built by ClassificationHeadMixin._build_classifier — a lucid.nn.Sequential wrapping lucid.nn.Dropout and lucid.nn.Linear.

Notes

The classification flow is

logits=W Drop⁡ ⁣(GAP⁡( backbone(x) ))+b.\text{logits} = W \,\operatorname{Drop}\!\left( \operatorname{GAP}(\,\mathrm{backbone}(x)\,) \right) + b.

Chollet (2017) reports 79.0% top-1 ImageNet validation accuracy with this configuration at the 299×299 input resolution, edging out Inception-v3's 78.2% at the same parameter count (~22.9M).

Examples

Run inference at the native 299×299 input resolution:
>>> import lucid
>>> from lucid.models.vision.xception import xception_cls
>>> model = xception_cls()
>>> x = lucid.randn(4, 3, 299, 299)
>>> out = model(x)
>>> out.logits.shape
(4, 1000)

Used by 2

Constructors

1
dunder

__init__

→None
__init__(config: XceptionConfig)

Instance methods

1
fn

forward

→XceptionOutput
forward(x: Tensor, labels: Tensor | None = None)

Override in subclasses to define the computation.