Skip to content
class

InceptionV3ForImageClassification

extendsImageClassificationModelClassificationHeadMixin
InceptionV3ForImageClassification(config: InceptionConfig)

Inception v3 image classifier with optional auxiliary classifier.

Combines an InceptionV3 backbone with a global-average-pool

  • lucid.nn.Dropout (p=config.dropout, default 0.5) + lucid.nn.Linear head producing config.num_classes logits. When config.aux_logits=True, an auxiliary classifier (_InceptionAux) attaches after the last 17×1717\times17 Inception-C block and contributes a 0.4-weighted cross-entropy term during training.

Parameters

Architecture spec. Use inception_v3_cls for the timm-compatible default (no auxiliary head). Pass aux_logits=True to enable the auxiliary classifier — used during training to combat vanishing gradients and provide intermediate supervision.

Attributes

Stored copy of the config that built this model.
stem, inception_a0, ..., inception_e1, reduction_a, reduction_b
Same backbone components as on InceptionV3.
Final global average pool to 1×11\times1.
Dropout applied before the main classifier (p=config.dropout, 0.5 in the paper).
classifiernn.Module
Final linear projection 2048 → num_classes.
Auxiliary classifier (_InceptionAux) when config.aux_logits=True; otherwise lucid.nn.Identity.

Notes

From Szegedy et al., "Rethinking the Inception Architecture for Computer Vision", CVPR 2016, §6. Total loss with auxiliary head is

L=Lmain+0.4⋅Laux.\mathcal{L} = \mathcal{L}_{\text{main}} + 0.4 \cdot \mathcal{L}_{\text{aux}}.

The paper also introduces label smoothing — replacing the one-hot target with (1−ϵ) 1y+ϵ/K(1 - \epsilon)\,\mathbf{1}_y + \epsilon/K — although that is a training-loop concern handled outside this module. Final top-5 ImageNet validation error in the paper is 3.5% with ≈24 M parameters.

Examples

Inference path (auxiliary head ignored even if enabled):
>>> import lucid
>>> from lucid.models.vision.inception import inception_v3_cls
>>> model = inception_v3_cls().eval()
>>> x = lucid.randn(2, 3, 299, 299)
>>> out = model(x)
>>> out.logits.shape
(2, 1000)

Used by 2

Constructors

1
dunder

__init__

→None
__init__(config: InceptionConfig)

Instance methods

1
fn

forward

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

Override in subclasses to define the computation.