Expand description
LeNet-5 — Yann LeCun’s convolutional network for MNIST (1998).
Original paper: “Gradient-Based Learning Applied to Document Recognition” LeCun, Bottou, Bengio, Haffner (1998).
Architecture (adapted to use ReLU in place of the original tanh/sigmoid):
Input [N, 1, 28, 28]
Conv2d(1→6, 5×5, pad=2) → [N, 6, 28, 28] (same-padding keeps spatial dims)
ReLU
AvgPool2d(2×2, stride=2) → [N, 6, 14, 14]
Conv2d(6→16, 5×5, pad=0) → [N, 16, 10, 10]
ReLU
AvgPool2d(2×2, stride=2) → [N, 16, 5, 5]
Flatten → [N, 400]
Linear(400→120)
ReLU
Linear(120→84)
ReLU
Linear(84→10)
Softmax(dim=1) → [N, 10] class probabilitiesThis example traces the model symbolically using SymTensor, extracts the
computation graph, and prints every node in topological order.
Re-exports§
pub use dataset::MnistBatch;pub use dataset::MnistDataset;
Modules§
- dataset
- MNIST parquet dataset reading. Reader for HuggingFace MNIST parquet files.
Functions§
- mnist
- Another LeNet-5 pipeline (see
mnist_lenet5), with biased convolutions and same-padding on the first layer. - mnist_
lenet5 - LeNet-5 (valid-convolution variant) — no padding, no bias, returns raw logits. Use this for training with a cross-entropy loss kernel that computes log-softmax internally.
- mnist_
mlp - Fully-connected MLP for MNIST — no conv layers, suitable for end-to-end training.
- mnist_
valid - LeNet-5 (valid-convolution variant) — no padding, no bias, with final softmax. Use this for inference when you need class probabilities.