File size: 1,142 Bytes
19b2807
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
---
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.