--- library_name: pytorch pipeline_tag: image-classification tags: - mnist - image-classification - pytorch license: mit --- # MNIST CNN (1-minute test run) A small CNN trained from scratch on [`ylecun/mnist`](https://huggingface.co/datasets/ylecun/mnist) for a fixed **60-second** wall-clock budget (13129 steps, ~28.01 epochs). ## Results | Metric | Value | | --- | --- | | Test accuracy | **0.9939** | | Test loss | 0.0232 | | Training wall-clock | 60.0s | | Steps | 13129 | | Throughput | 27993 images/s | ## Architecture `Conv(1->32, 3x3) -> ReLU -> MaxPool(2)` -> `Conv(32->64, 3x3) -> ReLU -> MaxPool(2)` -> `Flatten` -> `Linear(3136->128) -> ReLU` -> `Linear(128->10)`. Defined in `model.py`. ## Usage ```python import torch from model import SmallCNN model = SmallCNN() state = torch.load("model.pt", map_location="cpu") model.load_state_dict(state["model_state_dict"]) model.eval() # Input: float tensor (N, 1, 28, 28) scaled to [0, 1], then normalized x = (x - 0.1307) / 0.3081 logits = model(x) pred = logits.argmax(1) ``` Training preprocessing also applied random translation (pad 2, random crop) to the train split.