TinyDigitNet

A 14,410-parameter CNN for 28x28 grayscale digits, sized to run under ExecuTorch on Zephyr RTOS boards with no delegate: it has been run on an RP2040 (Cortex-M0+, Arducam Pico4ML-BLE, reading digits from the on-board camera), an ESP32-S3 (Seeed XIAO ESP32S3 Sense), an ESP32 (M5Stack ATOM) and Cortex-M33 parts (Arduino UNO Q, nRF5340, MCX N947).

conv1 1->8 3x3, ReLU, maxpool 2      28x28 -> 13x13
conv2 8->16 3x3, ReLU, maxpool 2     13x13 -> 5x5
fc1 400->32, ReLU
fc2 32->10

Input: (1, 1, 28, 28) float, pixel/255 normalised with mean 0.1307 and std 0.3081 (the usual MNIST constants; the firmware applies the same transform to camera crops). Output: 10 logits.

Files

File What
tiny_digit_net.py model definition (PyTorch)
tiny_digit_net.pt trained state dict, fp32
executorch/fp32.pte ExecuTorch program, portable fp32 kernels (62.8 KB)
executorch/int8-cmsis-m0plus.pte, -m4.pte, -m33.pte, -m7.pte int8 via the ExecuTorch Cortex-M quantizer and CortexMPassManager, one per core (25.4 KB)
tflite/fp32.tflite, tflite/int8.tflite the same weights through a Keras twin, for TensorFlow Lite Micro comparisons (post-training int8 quantization)
test_vectors.h one test image plus reference logits for an on-device self-test

Results

Metric Value
MNIST test accuracy (fp32) 97.46 %
Parameters 14,410
Inference, RP2040 @ 133 MHz, fp32 portable kernels 766 ms

Training

Standard MNIST, Adam, a few epochs on CPU; the script is train/train_mnist.py in the Pico4ML-BLE repo. Export with torch.export then to_edge_transform_and_lower(...).to_executorch(); the int8 variants use CortexMQuantizer + prepare_pt2e/convert_pt2e and the Cortex-M pass manager from ExecuTorch 1.5.

Where it runs

License

Apache-2.0. MNIST is the public dataset by LeCun, Cortes and Burges.

Downloads last month
50
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Dataset used to train eoinedge/TinyDigitNet

Evaluation results

  • Top-1 accuracy (fp32, 10,000 test images) on MNIST test set
    self-reported
    0.975