2025ML · Education

Neural Network Visualization

A desktop application that shows, step by step, how a neural network written from scratch in NumPy learns to recognize handwritten digits.

Neural Network Visualization screenshot

Overview

NeuralNetworkVisualization is a desktop application that visualizes, step by step, how a neural network learns and makes predictions. The user builds their own network and then watches every stage of its work: passing data forward through the layers, calculating the error and updating the weights during backpropagation.

The goal is to make the inner workings of a neural network easy to see and understand, instead of treating it as a black box. The project was created as part of a university course on neural networks.

The network

The network learns to recognize handwritten digits (0-9) from the digits dataset included in scikit-learn, where each digit is an 8×8 pixel image.

It is implemented from scratch using only NumPy and uses:

  • ReLU activation in the hidden layers
  • softmax activation in the output layer
  • cross-entropy as the error function
  • backpropagation with gradient descent

How it works

Configurator

On launch, a configurator window lets the user design the network structure:

  • the input layer has a fixed size of 64 neurons, one per pixel
  • the output layer has a fixed size of 10 neurons, one per digit
  • hidden layers can be added and removed freely, each with 1 to 32 neurons

Animation

The animation window displays the whole network, including neurons, connections and their current values, next to the current digit image and the training and testing controls.

Training can be run at different granularities:

  • Training Step: a single step (one layer forward, the error calculation, or one layer backward)
  • Train Epoch: one pass over the whole training set
  • Train Full: all 10 epochs
  • Reset Network: start again with new random weights

In the testing section, Predict Step passes a test sample through the trained network layer by layer, so the user can see how it reaches its answer.

The view is interactive: hovering over a neuron highlights its connections, clicking selects it and shows only its connections with their weights, dragging moves the view and the right arrow key performs the next step.

Results

To check that the implementation is correct, a 64-32-10 network was trained 100 times with a learning rate of 0.01 for 10 epochs, measuring accuracy on the test set (20% of the data) after every epoch.

Accuracy over epochs
EpochMedian accuracy
172.2%
288.3%
593.6%
1095.3%

The network reaches over 95% accuracy after 10 epochs.

Usage

The project requires Python 3.10 or newer with Tkinter:

git clone https://github.com/CenturionTheMan/NeuralNetworkVisualization.git
cd NeuralNetworkVisualization
pip install -r requirements.txt
cd src
python main.py
View code on GitHub
Next project Deepfake Detection Under Attribute Shift →