class
ResNeStForImageClassification
extends
PretrainedModelClassificationHeadMixinResNeStForImageClassification(config: ResNeStConfig)ResNeSt with global-average-pooled linear classification head.
Combines a ResNeSt backbone with global average
pooling, an optional lucid.nn.Dropout (probability
config.dropout), and a linear projection to
config.num_classes logits. When labels are supplied
to forward, a cross-entropy loss is computed and
returned alongside the logits.
Parameters
configResNeStConfigArchitecture spec. Use the
*_cls factory functions
(resnest_50_cls, resnest_101_cls, …) for
paper-cited configurations.Attributes
configResNeStConfigStored copy of the config that built this model.
conv1, bn1, act1, maxpool, layer1, layer2, layer3, layer4Same backbone components as on
ResNeSt; see that
class for shape semantics.avgpoolnn.AdaptiveAvgPool2dGlobal average pool collapsing the final feature map to
1 × 1.classifiernn.ModuleBuilt by
ClassificationHeadMixin._build_classifier —
a lucid.nn.Linear (or lucid.nn.Sequential
with dropout) projecting from 2048 channels to
config.num_classes.Notes
The classification flow is
Examples
Run inference on a batch of 224×224 RGB images:
>>> import lucid
>>> from lucid.models.vision.resnest import resnest_50_cls
>>> model = resnest_50_cls()
>>> x = lucid.randn(4, 3, 224, 224)
>>> out = model(x)
>>> out.logits.shape
(4, 1000)Used by 2
Constructors
1Instance methods
1forward(x: Tensor, labels: Tensor | None = None)