Skip to content
class

GoogLeNet

extendsPretrainedModelBackboneMixin
GoogLeNet(config: GoogLeNetConfig)

GoogLeNet (Inception v1) feature-extracting backbone.

Implements the 22-layer Inception v1 network from Szegedy et al., "Going Deeper with Convolutions", CVPR 2015: a five-block stem (Conv 7×77\times7 stride-2 → MaxPool → 1×11\times1 → 3×33\times3 → MaxPool) followed by nine _InceptionModule blocks grouped into three stages (Inception 3a-3b → MaxPool → 4a-4e → MaxPool → 5a-5b) and a final lucid.nn.AdaptiveAvgPool2d to a 1×11\times1 spatial map. Every convolution is batch-normalised, matching the canonical distributed ImageNet checkpoint. The two auxiliary classifiers attached at Inception 4a and 4d in the original paper are part of the classifier variant only, not the backbone.

Parameters

Frozen architecture spec. Use googlenet for the paper-cited configuration; pass a custom config to switch input channel count. aux_logits is irrelevant for the backbone.

Attributes

Stored copy of the config that built this model.
conv1, conv2, conv3_BasicConv2d
The pre-Inception conv stack.
maxpool1, maxpool2nn.MaxPool2d
Stem 3×33\times3 stride-2 ceil-mode max-pools.
inception3a, inception3b_InceptionModule
First Inception stage, producing a 28×2828\times28 spatial map with 256 and 480 channels respectively.
inception4a … inception4e_InceptionModule
Second Inception stage at 14×1414\times14 resolution; widths ramp 512 → 512 → 512 → 528 → 832.
inception5a, inception5b_InceptionModule
Third Inception stage at 7×77\times7 resolution, producing the final 1024-channel feature map.
maxpool3, maxpool4nn.MaxPool2d
Ceil-mode max-pools between Inception stages (3×33\times3 stride-2 and 2×22\times2 stride-2).
Final global average pool collapsing the 7×77\times7 feature map to 1×11\times1.
feature_infolist[FeatureInfo]
Per-stage descriptor (channels + reduction factor) exposed via BackboneMixin.

Notes

Each _InceptionModule computes four parallel branches in a single layer:

y=concat(f1×1(x),  f3×3(g1×1(x)),  f3×3(h1×1(x)),  p1×1(pool(x))).y = \mathrm{concat}\bigl( f_{1\times1}(x),\; f_{3\times3}(g_{1\times1}(x)),\; f_{3\times3}(h_{1\times1}(x)),\; p_{1\times1}(\mathrm{pool}(x)) \bigr).

The 1×11\times1 bottlenecks before the larger spatial convolutions keep the parameter count manageable: GoogLeNet has only ≈6.8 M parameters compared with ≈60 M for AlexNet, despite being substantially deeper and reaching a top-5 ImageNet validation error of 6.67%. This was the ILSVRC-2014 classification winner.

Examples

Build a GoogLeNet backbone and run a single forward pass:
>>> import lucid
>>> from lucid.models.vision.googlenet import googlenet
>>> backbone = googlenet()
>>> x = lucid.randn(2, 3, 224, 224)
>>> out = backbone(x)
>>> out.last_hidden_state.shape
(2, 1024, 7, 7)

Used by 2

Constructors

1
dunder

__init__

→None
__init__(config: GoogLeNetConfig)

Instance methods

2
fn

forward_features

→Tensor
forward_features(x: Tensor)

Run the backbone's feature-extraction pass.

Parameters

Input image batch, shape (B, C, H, W).

Returns

Tensor

Feature 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.