InceptionResNetV2
PretrainedModelBackboneMixinInceptionResNetV2(config: InceptionResNetConfig)Inception-ResNet v2 feature-extracting backbone.
Implements the residual-Inception topology from Szegedy et al.,
"Inception-v4, Inception-ResNet and the Impact of Residual
Connections on Learning", AAAI 2017. The body consists of three
residual Inception block families — _Block35 (×10),
_Block17 (×20), and _Block8 (×9 + 1 no-ReLU
block) — separated by Reduction-A (_Mixed6a) and
Reduction-B (_Mixed7a) blocks, with a leading Mixed_5b
pre-block (_Mixed5b) and a final
projection (conv2d_7b) to 1536 channels. Designed for
RGB inputs. State-dict naming matches the
canonical timm / TensorFlow-Slim implementation so weight transfer
is straightforward.
Parameters
configInceptionResNetConfiginception_resnet_v2 for
the paper-cited configuration with the recommended residual
scale factors (0.17 / 0.10 / 0.20).Attributes
configInceptionResNetConfigconv2d_ 1a, conv2d_ 2a, conv2d_ 2b, conv2d_ 3b, conv2d_ 4ann.Modulemixed_ 5b_Mixed5brepeatnn.Sequential_Block35 residual Inception-A blocks.mixed_ 6a_Mixed6arepeat_ 1nn.Sequential_Block17 residual Inception-B blocks.mixed_ 7a_Mixed7arepeat_ 2nn.Sequential_Block8 residual Inception-C blocks.block8_Block8conv2d_ 7b_ConvBnReLUavgpoolnn.AdaptiveAvgPool2dfeature_ infolist[FeatureInfo]BackboneMixin.Notes
Each residual Inception block computes
with a small fixed scale factor (0.10–0.20). The residual-scale trick was introduced specifically for Inception-ResNet because unscaled residuals caused training to diverge on networks with many filters per Inception module. Approximately 55.8 M parameters; achieves a top-5 ImageNet validation error of 3.08% in the original paper.
Examples
>>> import lucid
>>> from lucid.models.vision.inception_resnet import inception_resnet_v2
>>> backbone = inception_resnet_v2()
>>> x = lucid.randn(1, 3, 299, 299)
>>> out = backbone(x)
>>> out.last_hidden_state.shape # (B, 1536, 1, 1)
(1, 1536, 8, 8)Used by 2
Constructors
1Instance methods
2forward(x: Tensor)Override in subclasses to define the computation.
Run the backbone's feature-extraction pass.
Parameters
(B, C, H, W).Returns
TensorFeature 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.