ResNeXt feature-extracting backbone (no classification head).
Implements the grouped-convolution residual topology from Xie et
al., "Aggregated Residual Transformations for Deep Neural
Networks", CVPR 2017. Macroscopically identical to ResNet-50+ — a
stride-2 stem, a stride-2
max-pool, then four stages of _ResNeXtBottleneck blocks
producing feature maps at strides 4, 8, 16, 32. Microscopically
different: the convolution inside each bottleneck
is grouped into config.cardinality groups of
config.width_per_group channels each, which is mathematically
equivalent to summing the outputs of cardinality parallel
low-dimensional residual branches.
Parameters
configResNeXtConfigresnext_50_32x4d, resnext_101_32x8d, …) for
paper-cited configurations.Attributes
configResNeXtConfigstemnn.Sequentialmaxpoolnn.MaxPool2dlayer1, layer2, layer3, layer4nn.Sequential_ResNeXtBottleneck blocks.
layer1 keeps the input spatial size; layer2 / layer3
/ layer4 each halve it. All four end with 2048 channels
(same as ResNet-50+ — only the internal width changes).feature_infolist[FeatureInfo]BackboneMixin.Notes
A ResNeXt block of cardinality computes
where each is a low-dimensional
bottleneck. This
"split-transform-merge" pattern is implemented as a single
bottleneck with a groups=C convolution — a
one-line change versus ResNet but a substantial accuracy gain at
matched FLOPs. ResNeXt-50 (32x4d) outperforms ResNet-50 by roughly
one percentage point on ImageNet top-1 at the same compute budget.
Examples
Build a ResNeXt-50 (32x4d) backbone:
>>> import lucid
>>> from lucid.models.vision.resnext import resnext_50_32x4d
>>> backbone = resnext_50_32x4d()
>>> x = lucid.randn(1, 3, 224, 224)
>>> out = backbone(x)
>>> out.last_hidden_state.shape # (B, 2048, 7, 7)
(1, 2048, 7, 7)