Skip to content
class

ResNeXtForImageClassification

extendsImageClassificationModelClassificationHeadMixin
ResNeXtForImageClassification(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

Architecture spec. Use the *_cls factory functions (resnext_50_32x4d_cls, resnext_101_32x8d_cls, …) for paper-cited configurations.

Attributes

Stored copy of the config that built this model.
stem, maxpool, layer1, layer2, layer3, layer4
Same backbone components as on ResNeXt.
Global average pool to 1×11\times1.
classifiernn.Module
Final 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

L=−1N∑n=1Nlog⁡softmax⁡(logitsn) yn.\mathcal{L} = -\frac{1}{N} \sum_{n=1}^{N} \log \operatorname{softmax}(\text{logits}_n)_{\,y_n}.

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

1
dunder

__init__

→None
__init__(config: ResNeXtConfig)

Instance methods

1