Skip to content
class

InceptionV4

extendsPretrainedModelBackboneMixin
InceptionV4(config: InceptionV4Config)

Inception-v4 feature-extracting backbone.

Implements the non-residual network of Szegedy et al., "Inception-v4, Inception-ResNet and the Impact of Residual Connections on Learning", AAAI 2017 (Figure 9): the multi-branch stem of Figure 3, four Inception-A modules, Reduction-A, seven Inception-B modules, Reduction-B, and three Inception-C modules. Designed for 299×299299\times299 RGB inputs, which it maps to an 8×8×15368\times8\times1536 feature map.

Parameters

Frozen architecture spec. Use inception_v4 for the paper configuration.

Attributes

Stored copy of the config that built this model.
The 22-module trunk: features.0–features.5 are the stem, 6–9 Inception-A, 10 Reduction-A, 11–17 Inception-B, 18 Reduction-B and 19–21 Inception-C.
feature_infolist[FeatureInfo]
One entry per stage boundary — channels 64 / 160 / 384 / 1024 / 1536 at reductions 2 / 4 / 8 / 16 / 32.

Notes

Every module is a filter concatenation of parallel branches,

y=concat⁡(B1(x),…,Bk(x)),y = \operatorname{concat}\big(\mathcal{B}_1(x), \dots, \mathcal{B}_k(x)\big),

with no residual shortcut anywhere — that is what separates Inception-v4 from its sibling Inception-ResNet. The trunk holds 41.1 M parameters; the paper reports 20.0% top-1 / 5.0% top-5 single-crop error on the ImageNet validation set for the full classifier.

Examples

>>> import lucid
>>> from lucid.models.vision.inception_v4 import inception_v4
>>> backbone = inception_v4().eval()
>>> x = lucid.randn(1, 3, 299, 299)
>>> backbone.forward_features(x).shape
(1, 1536, 8, 8)
>>> [f.num_channels for f in backbone.feature_info]
[64, 160, 384, 1024, 1536]

Used by 2

Constructors

1
dunder

__init__

→None
__init__(config: InceptionV4Config)

Instance methods

2
fn

forward

→BaseModelOutput
forward(x: Tensor)

Return the trunk's feature map as last_hidden_state.

Parameters

Input images of shape (B, in_channels, H, W).

Returns

BaseModelOutput

last_hidden_state of shape (B, 1536, H', W').

fn

forward_features

→Tensor
forward_features(x: Tensor)

Run the trunk and return the final 8×8×15368\times8\times1536 map.

Parameters

Input images of shape (B, in_channels, H, W).

Returns

Tensor

Unpooled Inception-C output of shape (B, 1536, H', W') (8×8 at the native 299×299).