class
SENetForImageClassification
extends
PretrainedModelClassificationHeadMixinSENetForImageClassification(config: SENetConfig)SE-ResNet with global-average-pooled linear classification head.
Combines a SENet backbone with global average pooling
and a linear projection (fc) to config.num_classes
logits. When labels are supplied to forward, a
cross-entropy loss is computed and returned alongside the
logits.
Parameters
configSENetConfigArchitecture spec. Use the
*_cls factory functions
(se_resnet_18_cls through se_resnet_152_cls)
for paper-cited configurations.Attributes
configSENetConfigStored copy of the config that built this model.
conv1, bn1, maxpool, layer1, layer2, layer3, layer4Same backbone components as on
SENet; see that
class for shape semantics.avgpoolnn.AdaptiveAvgPool2dGlobal average pool collapsing the final feature map to
1 × 1.Linear projection from
hidden_sizes[3] * block.expansion
(512 for BasicBlock, 2048 for Bottleneck) to
config.num_classes.Notes
State-dict keys follow timm's seresnet layout
(conv1.*, bn1.*, layer{1-4}.*, fc.*) so that
pretrained weight files round-trip without renaming.
Examples
Run inference on a batch of 224×224 RGB images:
>>> import lucid
>>> from lucid.models.vision.senet import se_resnet_50_cls
>>> model = se_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)