class
ResNeXtForImageClassification
extends
PretrainedModelClassificationHeadMixinResNeXtForImageClassification(config: ResNeXtConfig)ResNeXt image classifier (backbone + GAP + linear head).
Combines a ResNeXt backbone with the standard ImageNet
head: lucid.nn.AdaptiveAvgPool2d to pool every spatial
location into a single 2048-dim feature, an optional
lucid.nn.Dropout (controlled by config.dropout), and
a lucid.nn.Linear projection to config.num_classes.
When labels are supplied to forward, a cross-entropy
loss is returned alongside the logits.
Parameters
configResNeXtConfigArchitecture spec. Use the
*_cls factory functions
(resnext_50_32x4d_cls, resnext_101_32x8d_cls,
…) for paper-cited configurations.Attributes
configResNeXtConfigStored copy of the config that built this model.
stem, maxpool, layer1, layer2, layer3, layer4Same backbone components as on
ResNeXt.avgpoolnn.AdaptiveAvgPool2dGlobal average pool to .
classifiernn.ModuleFinal classifier built by
ClassificationHeadMixin._build_classifier; bare linear
if dropout == 0.0, otherwise a
lucid.nn.Sequential wrapping
lucid.nn.Dropout and lucid.nn.Linear.Notes
From Xie et al., "Aggregated Residual Transformations for Deep Neural Networks", CVPR 2017. Loss is the standard categorical cross-entropy
The headline ImageNet result is ResNeXt-101 (64x4d) reaching 20.4% top-1 error — meaningfully better than ResNet-152 at the same FLOP budget.
Examples
>>> import lucid
>>> from lucid.models.vision.resnext import resnext_50_32x4d_cls
>>> model = resnext_50_32x4d_cls()
>>> x = lucid.randn(2, 3, 224, 224)
>>> out = model(x)
>>> out.logits.shape
(2, 1000)Used by 2
Constructors
1Instance methods
1forward(x: Tensor, labels: Tensor | None = None)