An interactive neural network. Paint a digit in a 28×28 grid with the mouse, press space, and the model tells you which digit it thinks you drew. Press t to train it on MNIST and watch the cost fall, then press y to measure its accuracy.
The point is to make backpropagation and weight initialization something you can poke at rather than read about. Every prediction is computed live from the pixels under your cursor.
| Input | Action |
|---|---|
| Left mouse button, drag | Paint the digit |
| space | Predict the drawn digit, printed to the terminal |
| r | Clear the grid |
| t | Train on MNIST |
| y | Report accuracy on the MNIST test set |
| s | Save the current weights to data/mnist/trained.mlp |
Predictions and training progress are printed to the terminal that launched the program, not drawn in the window.
The project targets a desktop OpenGL 3.3 core profile, so it needs a GPU and driver that can provide one. It builds on macOS and Linux, and CI runs it on Ubuntu.
Building requires a C++23 compiler, CMake, and a few system libraries.
Needs Xcode or the Command Line Tools for a C++23 compiler, plus CMake.
xcode-select --install
brew install cmakemacOS is detected automatically and the required system frameworks are linked for you. No OpenGL library needs to be installed, since the system provides it.
sudo apt-get install -y g++-14 cmake libwayland-dev libxkbcommon-dev xorg-devlibwayland-dev, libxkbcommon-dev, and xorg-dev are what GLFW needs to
create a window on Linux.
Clone with the submodules, since GLFW and FreeType are pulled in as git submodules and both need to be compiled before the project can link against them.
git clone --recursive https://github.com/nycrat/deep-learning-visualizer
cd deep-learning-visualizerThen build the dependencies. This installs GLFW and FreeType into external/,
which is where the build looks for them.
./scripts/setup.shThe MNIST files are already committed under data/mnist/, so there is nothing
else to download.
Finally, build and run:
make
make runmake produces a debug build in bin/debug/. Set BUILD_TYPE=release for an
optimized build in bin/release/:
make BUILD_TYPE=releaseRelease builds use -O3 -march=native, so they are fast but not portable
between machines.
make test
make test BUILD_TYPE=releaseSee docs/testing.md for how the suite is laid out and how to write new tests.
make docsDoxygen writes the site to docs/html, starting at docs/html/index.html. It
is also published to GitHub Pages on every push; see
.github/workflows/docs.yml.
To get LSP working properly, use bear:
make clean
bear -- make