ResNet BasicBlock training example (small CHW) #
This next-step file demonstrates the public API.nn.blocks.resnetBasicBlock builder on a small 4×4
"band" dataset (vertical vs horizontal bars).
It is intentionally not part of the first quickstart path. It is here as a compact bridge from the
basic MLP/CNN tutorials to the maintained model-zoo ResNet example under NN/Examples/Models.
Note: this particular example uses BatchNorm blocks, so the model is built for a fixed batch size.
Most other tutorials in this folder use batch-free models and let API.train.runLoader* lift them.
Check this tutorial module directly:
lake build NN.Examples.Quickstart.ResnetBasicblockTrain
For the maintained command-line ResNet trainer, use NN/Examples/Models/Vision/Resnet.lean:
python3 scripts/datasets/download_example_data.py --cifar10lake exe torchlean resnet --cpu --n-total 20 --steps 1
Optional flags:
--epochs E--quick(skip expensive before/after evaluation reports; intended for CI/smoke runs)
Public API used here:
nn.conv,nn.batchNorm,nn.resnetBasicBlocknn.flattenBatch,nn.linearData.batchLoadertrain.fitLoaderWith+train.Callbacks
Reader note:
- this is the one tutorial here whose model is already batched in its type because BatchNorm uses cross-batch statistics;
- so the task shape is fixed to the chosen
--batchsize and the loader usesdrop_last=true; Semantics.Scalar α/Runtime.Scalar αstill mean "the chosen scalar backend supports the math" and "the backend is executable".
See NN/Examples/Quickstart/README.md for the shared conventions in this folder.
Why this tutorial exists:
- it shows how TorchLean exposes residual CNN blocks, not just plain sequential stacks;
- it gives users one clean example of fixed-batch training, which matters once BatchNorm enters the model;
- it stays small enough to read in one sitting while still looking recognizably "ResNet-like".
Instances For
Run one training session on the small band-image dataset.
This is intentionally separated from main so the tutorial keeps a clean “build task, choose
backend, then train” structure.