class
SKNetForImageClassification
extends
PretrainedModelClassificationHeadMixinSKNetForImageClassification(config: SKNetConfig)SK-ResNet with global-average-pooled linear classification head.
Combines an SKNet backbone with global average
pooling 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
configSKNetConfigArchitecture spec. Use the
*_cls factory functions
(sk_resnet_18_cls through
sk_resnext_50_32x4d_cls) for paper-cited
configurations.Attributes
configSKNetConfigStored copy of the config that built this model.
stem, maxpool, layer1, layer2, layer3, layer4Same backbone components as on
SKNet; 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 512 (basic) or 2048
(bottleneck) 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.sknet import sk_resnet_50_cls
>>> model = sk_resnet_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)