ResNet
28 memberslucid.models.vision.resnetResNet model family — feature-extracting backbones and image classifiers.
Implements the residual-learning architecture from He et al., "Deep Residual Learning for Image Recognition", CVPR 2016 (arXiv:1512.03385), plus a few widely-cited follow-up variants:
- Canonical ResNets —
resnet_18,resnet_34,resnet_50,resnet_101,resnet_152and their*_clsclassification counterparts. - Wide ResNets (Zagoruyko & Komodakis, BMVC 2016) —
wide_resnet_50,wide_resnet_101. - Deep bottleneck variants —
resnet_200,resnet_269.
Every variant shares the same architecture-specifying dataclass
ResNetConfig. Use the factory functions for paper-cited
configurations; pass **overrides to tweak individual fields without
writing a config by hand.
He, Kaiming, et al. "Deep Residual Learning for Image Recognition." Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, 2016, pp. 770–778.
Deep residual networks introduce identity shortcuts around every pair (or triple) of stacked convolutions. A residual block computes
where is the stacked-convolution branch and the addition is the identity shortcut. Reformulating the layer to learn a residual rather than the full mapping makes the optimisation surface dramatically easier — the network only has to fit the correction to the identity, which is closer to zero at initialisation than the full mapping is to the target.
Stacking these blocks lets gradient signals flow through dozens or hundreds of layers without vanishing. The paper showed networks up to 152 layers deep training stably on ImageNet, with each successive depth setting a new state-of-the-art at the time (3.57% top-5 error, winning ILSVRC 2015).
Two block topologies are used. BasicBlock (two 3×3 convs)
is used in ResNet-18/34. Bottleneck (1×1 → 3×3 → 1×1 with
a 4× channel expansion) is used in ResNet-50/101/152 and all
deeper / wider variants. The four ImageNet variants from Table 1
of the paper differ only in (block, [n₁, n₂, n₃, n₄]) where
is the block-repetition count at stage .
Classes
Functions
resnet_18→ ResNetResNet-18 feature-extracting backbone (no classification head).
resnet_18_cls→ ResNetForImageClassificationResNet-18 image classifier (backbone + GAP + linear head).
resnet_34→ ResNetResNet-34 feature-extracting backbone (no classification head).
resnet_34_cls→ ResNetForImageClassificationResNet-34 image classifier (backbone + GAP + linear head).
resnet_50→ ResNetResNet-50 feature-extracting backbone (no classification head).
resnet_50_cls→ ResNetForImageClassificationResNet-50 image classifier (backbone + GAP + linear head).
resnet_101→ ResNetResNet-101 feature-extracting backbone (no classification head).
resnet_101_cls→ ResNetForImageClassificationResNet-101 image classifier (backbone + GAP + linear head).
resnet_152→ ResNetResNet-152 feature-extracting backbone (no classification head).
resnet_152_cls→ ResNetForImageClassificationResNet-152 image classifier (backbone + GAP + linear head).
wide_resnet_50→ ResNetWide ResNet-50-2 feature-extracting backbone (no classification head).
wide_resnet_50_cls→ ResNetForImageClassificationWide ResNet-50-2 image classifier (backbone + GAP + linear head).
wide_resnet_101→ ResNetWide ResNet-101-2 feature-extracting backbone (no classification head).
wide_resnet_101_cls→ ResNetForImageClassificationWide ResNet-101-2 image classifier (backbone + GAP + linear head).
resnet_200→ ResNetResNet-200 feature-extracting backbone (no classification head).
resnet_200_cls→ ResNetForImageClassificationResNet-200 image classifier (backbone + GAP + linear head).
resnet_269→ ResNetResNet-269 feature-extracting backbone (no classification head).
resnet_269_cls→ ResNetForImageClassificationResNet-269 image classifier (backbone + GAP + linear head).
Weights
ResNet18WeightsPretrained weight tags for lucid.models.resnet_18_cls.
ResNet34WeightsPretrained weight tags for lucid.models.resnet_34_cls.
ResNet50WeightsPretrained weight tags for lucid.models.resnet_50_cls.
ResNet101WeightsPretrained weight tags for lucid.models.resnet_101_cls.
ResNet152WeightsPretrained weight tags for lucid.models.resnet_152_cls.
WideResNet50WeightsPretrained weight tags for lucid.models.wide_resnet_50_cls.
WideResNet101WeightsPretrained weight tags for lucid.models.wide_resnet_101_cls.