AlexNet feature-extracting backbone (no fully-connected head).
Implements the single-stream, no-LRN derivation from Krizhevsky,
"One weird trick for parallelizing convolutional neural networks",
arXiv:1404.5997 — the canonical re-derivation of the original
Krizhevsky, Sutskever & Hinton 2012 two-GPU model into a single
merged stream with adjusted channel widths
. Five convolutions
( stride-4 first; second; three
), each followed by ReLU, with overlapping
stride-2 max-pools after blocks 1, 2, and 5. A
final lucid.nn.AdaptiveAvgPool2d collapses the feature
map to regardless of input resolution.
Parameters
configAlexNetConfigalexnet for the
paper-cited single-stream configuration; pass a custom config
to switch input channel count or to retarget the classifier
variant.Attributes
configAlexNetConfigfeaturesnn.Sequential_build_features for the exact ordering.avgpoolnn.AdaptiveAvgPool2dfeature_infolist[FeatureInfo]BackboneMixin for downstream decoder modules.Notes
From Krizhevsky 2014, §3. AlexNet's contribution to deep-learning history is threefold: the rectified linear unit replaced saturating nonlinearities and cut training time by several factors; dropout with regularised the 4096-dim fully-connected layers against overfitting on a 1.2 M-image dataset; and heavy data augmentation (random crop, horizontal flip, AlexNet-style PCA colour jitter) was made central to the recipe. The 2012 paper additionally used local response normalisation between blocks 1-2; the 2014 derivation drops it as compute-without-accuracy. The classifier variant has approximately 61.1 M parameters (≈58.6 M of which sit in the two 4096-dim fully-connected layers). With the original ImageNet-1k training recipe the single-stream AlexNet reaches roughly 56.5% top-1 / 79.1% top-5 on the validation split.
Examples
Build the backbone and run a single forward pass:
>>> import lucid
>>> from lucid.models.vision.alexnet import alexnet
>>> backbone = alexnet()
>>> x = lucid.randn(2, 3, 224, 224)
>>> out = backbone(x)
>>> out.last_hidden_state.shape # (B, 256, 6, 6)
(2, 256, 6, 6)
Inspect per-stage feature descriptors:
>>> info = backbone.feature_info
>>> [(fi.stage, fi.num_channels, fi.reduction) for fi in info[:2]]
[(1, 64, 4), (2, 192, 8)]Used by 2
Constructors
1Properties
1feature_info: list[FeatureInfo]Instance methods
2forward(x: Tensor)Run R-CNN on a batch of images.
Parameters
xproposalsNone to return empty detections.Returns
BaseModelOutputObjectDetectionOutput with:
logits : (Σ N_i, num_classes + 1) raw class logits.
pred_boxes : (Σ N_i, 4) decoded xyxy boxes (top class).