Skip to content

Randis12345/MNIST-C-Neural-Net

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MNIST C Neural Net

Web demo screenshot

A small educational MNIST neural-network implementation in C with:

  • a minimal fully-connected network (forward/backward) in layer.c/h and mnist_model.*
  • a CLI trainer/tester (train)
  • a Raylib-based desktop demo (main) where you can draw digits
  • a WebAssembly web demo (webapp/) built with Emscripten

Features

  • Train on the MNIST dataset and save/load parameters (weights.bin)
  • Real-time desktop drawing demo using Raylib
  • Browser demo (nn.js / index.html) with preprocessing and WASM inference

Requirements

  • gcc, make, curl, gunzip
  • raylib (for the desktop demo)
  • Emscripten (emcc) to build the web demo

Quickstart

  1. Fetch the MNIST dataset: ./download_mnist.sh

  2. Build native tools: make

  3. Train and save parameters (example): ./train save weights.bin # trains for a few epochs and writes weights

  4. Run tests against saved parameters: ./train load weights.bin

  5. Run the Raylib drawing demo (desktop GUI): ./main weights.bin

  6. Build the WebAssembly demo (requires emscripten): make nn.js (serve the webapp/ directory with a static server, e.g.) python3 -m http.server --directory webapp 8000 then open http://localhost:8000/

Files of interest

  • layer.c / layer.h — low-level layer implementation (forward/backward)
  • mnist_model.c / mnist_model.h — model wrapper, IO (load/save), train/test helpers
  • train.c — CLI for training/saving/loading/testing
  • main.c — Raylib desktop demo (draw digits & predict)
  • download_mnist.sh — downloads and unpacks MNIST into data/
  • Makefile — targets: make (native build), make train, make nn.js (emscripten)
  • webapp/ — browser UI, nn.js (WASM bootstrap), index.html, index.js
  • todo.txt — developer TODOs and cleanup notes

Notes & tips

  • The model saved format is a raw binary dump (weights then biases). Use ./train save to produce a compatible weights file.
  • Raylib demo links against system raylib; ensure your platform has it installed (package name often libraylib-dev / raylib).
  • The web demo embeds weights.bin via the Emscripten --embed-file flag in the Makefile.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors