InceptionV4ForImageClassification
ImageClassificationModelInceptionV4ForImageClassification(config: InceptionV4Config)Inception-v4 image classifier (trunk + GAP + dropout + linear).
Adds the paper's head to the InceptionV4 trunk: global
average pooling over the grid, dropout with keep
probability 0.8 (config.dropout = 0.2), and a single
lucid.nn.Linear layer producing config.num_classes
logits. The trunk is held directly as features and the head as
last_linear so the state dict matches the released checkpoint's
keys one-for-one.
Parameters
configInceptionV4Configinception_v4_cls for the paper
configuration.Attributes
configInceptionV4Configfeaturesnn.SequentialInceptionV4.features.global_poolnn.AdaptiveAvgPool2dhead_dropnn.Modulelucid.nn.Dropout when config.dropout > 0, otherwise
lucid.nn.Identity.last_linearnn.Linearnum_classes.Notes
The loss, computed only when labels is given, is the mean
categorical cross-entropy
42.7 M parameters in total. The paper reports 20.0% top-1 / 5.0% top-5 single-crop error on the ImageNet validation set (Table 2).
Examples
>>> import lucid
>>> from lucid.models.vision.inception_v4 import inception_v4_cls
>>> model = inception_v4_cls().eval()
>>> out = model(lucid.randn(2, 3, 299, 299))
>>> out.logits.shape
(2, 1000)Used by 2
Constructors
1Instance methods
2forward(x: Tensor, labels: Tensor | None = None)Classify a batch of images.
Parameters
Returns
InceptionV4Outputlogits of shape (B, num_classes) and loss (or
None).
Replace the classification head with a freshly initialised one.
The head keeps the checkpoint's last_linear attribute name, so
this cannot come from ClassificationHeadMixin (which looks for
self.classifier).
Parameters
num_classesint