A hands-on, beginner-oriented tutorial for training and deploying image classification neural networks with Caffe and NVIDIA DIGITS, no prior AI background needed.
itskonrad/tinymnist
A minimal neural network written in pure C that learns to classify handwritten MNIST digits in about 250 lines.
- Stars
- 1,287
- Forks
- 130
- Open issues
- 3
- Last commit
- 25 days ago
What is it?
tinymnist is a small neural network implemented in pure C that classifies handwritten digits from the MNIST dataset. The whole program is roughly 250 lines and depends only on the C standard library.
The model is a fully connected network with 784 inputs, a 256-unit ReLU hidden layer, and a 10-way softmax output, trained with cross-entropy loss and SGD with momentum. The MNIST training set is bundled in the data directory, so the program can be compiled with gcc and run directly.
The project reports about 98% test accuracy after 20 epochs, with each epoch taking roughly half a second. Training uses 80% of the data and the remaining 20% is held out for testing. Hyperparameters such as hidden size, learning rate, momentum, epoch count and train split are set through #define constants at the top of main.c.
Key features
- 01Pure C implementation with no dependencies beyond the standard library
- 02Two-layer fully connected network with ReLU and softmax
- 03Trains with cross-entropy loss and SGD with momentum
- 04Includes the MNIST training data, so it runs out of the box
- 05Hyperparameters are adjustable via #define constants
Use cases
- Learning how a neural network works at the lowest level
- Studying forward and backward passes without a deep learning framework
- A compact baseline for MNIST classification experiments
Quick start
- 1
Compile the program with gcc
gcc -O3 -march=native -ffast-math -o main main.c -lm - 2
Run the trained-from-scratch network (MNIST data is included in data/)
./main
Things to know
- Only a tiny teaching model, not a practical digit classifier for real-world use.
- Configuration requires editing #define constants in main.c and recompiling.
In collections
Topics
FAQ
- What is tinymnist?
- A minimal neural network written in pure C that learns to classify handwritten MNIST digits in about 250 lines. tinymnist is a small neural network implemented in pure C that classifies handwritten digits from the MNIST dataset. The whole program is roughly 250 lines and depends only on the C standard library.
- Is tinymnist free to use? What license does it have?
- tinymnist is open source under the MIT license. Check the license terms before using it in commercial products.
- Is tinymnist still maintained?
- Actively maintained. The last commit to tinymnist was on Oct 13, 2026.
- What can I use tinymnist for?
- Learning how a neural network works at the lowest level Studying forward and backward passes without a deep learning framework A compact baseline for MNIST classification experiments
- How do I install tinymnist?
- Compile the program with gcc: gcc -O3 -march=native -ffast-math -o main main.c -lm Run the trained-from-scratch network (MNIST data is included in data/): ./main
- Where can I get tinymnist?
- The source code and installation instructions are on GitHub: https://github.com/itskonrad/tinymnist
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A curated awesome-list cataloging PyTorch-related libraries, models, implementations, tutorials and papers on GitHub.
A deep learning server, Python wheel and CLI for training and running models on images, text, tabular and time-series data via a REST API.
An end-to-end open source platform for building and deploying machine learning models, with Python and C++ APIs.
A Python deep learning framework offering GPU-accelerated tensor computation and dynamic neural networks built on autograd.
A minimal deep learning framework with a PyTorch-like tensor API, autograd, a compiler, and support for many accelerator backends.