Aditya Sridhar

Model · Oct 2026 · runs in your browser

CNN on CIFAR-10

The MNIST network sees white strokes on black. Here the inputs are 32×32 colour photos of planes, cars, birds, cats and six other classes, at every angle and on any background. The same recipe of small convolutions, wider and deeper, and a heatmap of the part of the photo that decided the answer.

Test accuracy
89.69%
Parameters
288,746
Model file
1130 KB, ONNX
Training time
2.2 min, GPU

Try it

CIFAR-10 test images

Pick an image
32×32 pixels: the whole image, exactly as the model sees it.

Loading the model…

  1. airplane
  2. automobile
  3. bird
  4. cat
  5. deer
  6. dog
  7. frog
  8. horse
  9. ship
  10. truck

Runs in your browser. Nothing is uploaded.

The test images were never seen in training. Uploaded photos are centre-cropped and shrunk to 32×32 first, so pick one where the object fills the frame; CIFAR-10 has no people, so a selfie gets one of the ten classes anyway.

Training run

Accuracytrain (augmented)test
60%80%17131925313740epoch 1 · train (augmented) 47%epoch 2 · train (augmented) 65%epoch 3 · train (augmented) 72%epoch 4 · train (augmented) 76%epoch 5 · train (augmented) 78%epoch 6 · train (augmented) 80%epoch 7 · train (augmented) 81%epoch 8 · train (augmented) 82%epoch 9 · train (augmented) 83%epoch 10 · train (augmented) 83%epoch 11 · train (augmented) 84%epoch 12 · train (augmented) 84%epoch 13 · train (augmented) 84%epoch 14 · train (augmented) 85%epoch 15 · train (augmented) 85%epoch 16 · train (augmented) 85%epoch 17 · train (augmented) 85%epoch 18 · train (augmented) 86%epoch 19 · train (augmented) 86%epoch 20 · train (augmented) 86%epoch 21 · train (augmented) 86%epoch 22 · train (augmented) 87%epoch 23 · train (augmented) 87%epoch 24 · train (augmented) 87%epoch 25 · train (augmented) 87%epoch 26 · train (augmented) 88%epoch 27 · train (augmented) 88%epoch 28 · train (augmented) 89%epoch 29 · train (augmented) 89%epoch 30 · train (augmented) 89%epoch 31 · train (augmented) 90%epoch 32 · train (augmented) 90%epoch 33 · train (augmented) 91%epoch 34 · train (augmented) 92%epoch 35 · train (augmented) 92%epoch 36 · train (augmented) 93%epoch 37 · train (augmented) 94%epoch 38 · train (augmented) 95%epoch 39 · train (augmented) 95%epoch 40 · train (augmented) 95%epoch 1 · test 51%epoch 2 · test 57%epoch 3 · test 70%epoch 4 · test 65%epoch 5 · test 71%epoch 6 · test 76%epoch 7 · test 75%epoch 8 · test 74%epoch 9 · test 79%epoch 10 · test 73%epoch 11 · test 76%epoch 12 · test 81%epoch 13 · test 81%epoch 14 · test 80%epoch 15 · test 80%epoch 16 · test 80%epoch 17 · test 71%epoch 18 · test 77%epoch 19 · test 81%epoch 20 · test 79%epoch 21 · test 82%epoch 22 · test 79%epoch 23 · test 80%epoch 24 · test 79%epoch 25 · test 80%epoch 26 · test 83%epoch 27 · test 82%epoch 28 · test 83%epoch 29 · test 85%epoch 30 · test 85%epoch 31 · test 86%epoch 32 · test 87%epoch 33 · test 88%epoch 34 · test 87%epoch 35 · test 88%epoch 36 · test 89%epoch 37 · test 89%epoch 38 · test 90%epoch 39 · test 90%epoch 40 · test 90%
Losstraintest
0.5001.0001.50017131925313740epoch 1 · train 1.466epoch 2 · train 0.976epoch 3 · train 0.797epoch 4 · train 0.701epoch 5 · train 0.632epoch 6 · train 0.590epoch 7 · train 0.550epoch 8 · train 0.529epoch 9 · train 0.508epoch 10 · train 0.496epoch 11 · train 0.477epoch 12 · train 0.471epoch 13 · train 0.464epoch 14 · train 0.452epoch 15 · train 0.444epoch 16 · train 0.442epoch 17 · train 0.437epoch 18 · train 0.422epoch 19 · train 0.414epoch 20 · train 0.409epoch 21 · train 0.405epoch 22 · train 0.394epoch 23 · train 0.384epoch 24 · train 0.376epoch 25 · train 0.369epoch 26 · train 0.360epoch 27 · train 0.345epoch 28 · train 0.338epoch 29 · train 0.321epoch 30 · train 0.310epoch 31 · train 0.298epoch 32 · train 0.278epoch 33 · train 0.259epoch 34 · train 0.238epoch 35 · train 0.220epoch 36 · train 0.196epoch 37 · train 0.178epoch 38 · train 0.166epoch 39 · train 0.156epoch 40 · train 0.151epoch 1 · test 1.415epoch 2 · test 1.266epoch 3 · test 0.859epoch 4 · test 1.074epoch 5 · test 0.878epoch 6 · test 0.698epoch 7 · test 0.714epoch 8 · test 0.806epoch 9 · test 0.651epoch 10 · test 0.848epoch 11 · test 0.743epoch 12 · test 0.567epoch 13 · test 0.587epoch 14 · test 0.630epoch 15 · test 0.597epoch 16 · test 0.601epoch 17 · test 0.985epoch 18 · test 0.742epoch 19 · test 0.585epoch 20 · test 0.643epoch 21 · test 0.527epoch 22 · test 0.672epoch 23 · test 0.584epoch 24 · test 0.651epoch 25 · test 0.628epoch 26 · test 0.523epoch 27 · test 0.530epoch 28 · test 0.523epoch 29 · test 0.447epoch 30 · test 0.442epoch 31 · test 0.405epoch 32 · test 0.411epoch 33 · test 0.380epoch 34 · test 0.381epoch 35 · test 0.363epoch 36 · test 0.336epoch 37 · test 0.334epoch 38 · test 0.315epoch 39 · test 0.311epoch 40 · test 0.312

Results

MetricValueSource
Test accuracy, 10,000 images89.69%training/cnn_cifar10/log.csv, epoch 40
Test loss0.3119training/cnn_cifar10/log.csv, epoch 40
Train accuracy (augmented)95.08%training/cnn_cifar10/log.csv, epoch 40
Test accuracy of the exported ONNX file89.72%public/models/cnn-cifar10/meta.json
Small CNN on MNIST, for scale99.41%training/cnn_mnist/log.csv

How it works

Architecture. Three stages of two 3×3 convolutions with batch norm and ReLU, at 32, 64 and 128 channels, with a max pool between stages, so the maps go 32, 16, 8. A global average pool and one linear layer make the classifier.

Where it looked. Because the head is an average followed by a linear layer, the score for a class is the average over positions of a weighted sum of the last 128 maps. Drawing that weighted sum before averaging gives the class activation map (Zhou et al., 2016): an 8×8 grid that says how much each part of the image added to the score. It is computed inside the exported graph, with no gradients needed in the browser.

Training. SGD with Nesterov momentum, batch 128, weight decay 0.0005, a one-cycle learning rate peaking at 0.1 over 40 epochs, bf16 autocast. Augmentation is a random 32×32 crop from the image padded by 4 pixels, and a horizontal flip, done on the GPU.

Reproduce

Hardware
NVIDIA GeForce RTX 3050 Laptop GPU, PyTorch 2.6.0+cu124
Commit
83e9c8d
Data
CIFAR-10, 50,000 train / 10,000 test, binary release, MD5-checked by the script

Environment

pip install torch numpy onnx onnxruntime

Train, export and score the ONNX file

python training/cnn_cifar10/train.py