Skip to content
class

ResNeSt

extendsPretrainedModelBackboneMixin
ResNeSt(config: ResNeStConfig)

ResNeSt feature-extracting backbone (no classification head).

Implements the Split-Attention augmentation of the ResNet topology from Zhang et al., "ResNeSt: Split-Attention Networks", CVPR Workshops 2022 (arXiv:2004.08955). Each bottleneck's 3×33 \times 3 is replaced by a Split-Attention block that fuses ResNeXt cardinality, SKNet kernel selection, and SENet channel attention into a single unified primitive. The block splits the feature map into KK cardinal groups, then further splits each group into RR parallel radix branches, and computes per-radix softmax attention weights

ar,c=exp⁡(zr,c)∑r′=1Rexp⁡(zr′,c),Vc=∑r=1Rar,c⋅Ur,c.a_{r, c} = \frac{\exp(z_{r, c})}{\sum_{r'=1}^{R} \exp(z_{r', c})}, \qquad V_c = \sum_{r=1}^{R} a_{r, c} \cdot U_{r, c}.

Two further refinements complete the architecture: a deep stem (three 3×3 convolutions replacing the original 7×7 stem) and an average-pool downsampling path that replaces strided convolutions in residual shortcuts and inside the Split-Attention block itself.

Parameters

Frozen architecture spec. Use the factory functions (resnest_50, resnest_101, …) for paper-cited variants.

Attributes

Stored copy of the config that built this model.
Deep stem (three 3×3 convolutions) or single 7×7 conv, depending on config.deep_stem.
BatchNorm paired with the stem output.
Post-stem ReLU activation.
3×3 max-pool at stride 2.
layer1, layer2, layer3, layer4nn.Sequential
The four Split-Attention residual stages. Output strides are 4, 8, 16, and 32 relative to the input.
feature_infolist[FeatureInfo]
Per-stage descriptor (channels + reduction factor) exposed via BackboneMixin.

Notes

When R=1R = 1 the Split-Attention block degenerates to ResNeXt; at R≥2R \geq 2 it generalises SKNet to arbitrary radix counts with a softmax (rather than two-way sigmoid) gate. ResNeSt-50 outperforms plain ResNet-50 by roughly 3 ImageNet top-1 percentage points at the same parameter count, and serves as a strong backbone for downstream detection / segmentation pipelines.

Examples

Build a ResNeSt-50 backbone and run a forward pass:
>>> import lucid
>>> from lucid.models.vision.resnest import resnest_50
>>> backbone = resnest_50()
>>> x = lucid.randn(2, 3, 224, 224)
>>> out = backbone(x)
>>> out.last_hidden_state.shape
(2, 2048, 7, 7)

Used by 2

Constructors

1
dunder

__init__

→None
__init__(config: ResNeStConfig)

Instance methods

2
fn

forward_features

→Tensor
forward_features(x: Tensor)

Run the backbone's feature-extraction pass.

Parameters

Input image batch, shape (B, C, H, W).

Returns

Tensor

Feature map at the deepest stage. Concrete subclasses may additionally stash earlier stages on the instance so multi-stage consumers can fetch them.

Examples

The map returned is the one feature_info lists last, so a
neck can size itself from that entry without running the model.
>>> import lucid
>>> from lucid.models import create_model
>>> backbone = create_model("resnet_18").eval()
>>> last = backbone.feature_info[-1]
>>> last.num_channels, last.reduction
(512, 32)
>>> backbone.forward_features(lucid.randn((1, 3, 64, 96))).shape
(1, 512, 2, 3)
Each side is divided by the advertised reduction on its own, so
a non-square input keeps its aspect ratio.