LeNet-5 feature extractor (no fully-connected head).
Implements the canonical convolutional trunk of the original LeNet-5 network from LeCun et al., "Gradient-Based Learning Applied to Document Recognition", Proc. IEEE 1998: three convolutional layers (C1, C3, C5) interleaved with two sub-sampling layers (S2, S4). The receptive field grows from a single patch in C1 to the entire input by C5 — so for the canonical input size the C5 output collapses to a spatial map of 120 channels, acting as a fully-connected layer in conv form. Used as the canonical "Hello World" of convolutional networks and as the smallest paper-cited baseline in the model zoo.
Parameters
configLeNetConfiglenet_5 for the
paper-cited tanh + average-pool variant; pass a custom config to
switch to modern activation="relu" / pooling="max" or to
accept RGB input via in_channels=3.Attributes
configLeNetConfigfeaturesnn.Sequential_build_features for the exact layer chain.feature_infolist[FeatureInfo]BackboneMixin for downstream decoder modules.Notes
From LeCun et al., "Gradient-Based Learning Applied to Document Recognition", Proc. IEEE 86(11):2278–2324, 1998, Figure 2. Each convolution computes
where is in the paper. The original
sub-sampling layer was a trainable average pool
with learnable scale and bias; this implementation uses standard
parameter-free lucid.nn.AvgPool2d for compatibility with
modern training recipes. Total parameter count is approximately
60 k — small enough to train to convergence on MNIST in minutes on
a CPU.
Examples
Run a single forward pass on a batch of MNIST-shaped inputs:
>>> import lucid
>>> from lucid.models.vision.lenet import lenet_5
>>> backbone = lenet_5()
>>> x = lucid.randn(8, 1, 32, 32)
>>> out = backbone(x)
>>> out.last_hidden_state.shape # (B, 120, 1, 1)
(8, 120, 1, 1)Used by 2
Constructors
1Configure a DataLoader; see the class docstring for parameter
semantics.
Raises
ValueErrorNotes
sampler / batch_sampler / shuffle / batch_size /
drop_last interact: passing batch_sampler precludes the
other four; passing sampler precludes shuffle. When no
sampler is supplied, a SequentialSampler (shuffle=False)
or RandomSampler (shuffle=True) is constructed
automatically. persistent_workers requires num_workers > 0.
Properties
1feature_info: list[FeatureInfo]