Visualizing Neural Networks from the Inside Out: A Pure NumPy MLP Training Visualization Tool

A pure NumPy MLP with real-time visualization that exposes every detail of neural network training.
A developer has open-sourced a small MLP built entirely in NumPy — no autograd frameworks — aimed at ML students, self-learners, and educators. It hand-implements backpropagation, SGD with momentum, L2 regularization, dropout, and cosine annealing, achieving ~98.5% accuracy on MNIST. The real-time GUI displays loss curves, per-layer gradient norms, dead neuron ratios, weight distributions, and first-layer receptive fields. Built-in NumPy PCA and t-SNE enable layer-by-layer feature space analysis, with misclassified samples linked to their confused class clusters. A Neuron Laboratory supports ablation, pruning, noise injection, and softmax temperature tuning with instant accuracy feedback.
A Teaching Tool That Lets You "See" Inside a Neural Network
Understanding the neural network training process has always been one of the hardest hurdles in learning machine learning. How do weights change? How do gradients flow? What exactly does a given neuron learn? These questions often remain trapped in abstract mathematical formulas, making it difficult for students to build genuine intuition.
A developer shared an open-source project on Reddit's Machine Learning community: a small multi-layer perceptron (MLP) implemented entirely from scratch with NumPy, paired with a graphical interface that lets users observe everything happening inside the network in real time during training. The project is hosted on GitHub, with a clear target audience — from high school students to intro-course learners, self-taught practitioners, and teachers who want to demonstrate how networks work in the classroom.
The most notable aspect: the entire project does not rely on any automatic differentiation framework. Backpropagation, SGD with momentum, L2 regularization, dropout, cosine annealing learning rate scheduling, and four activation functions are all implemented by hand. This "reinventing the wheel" approach isn't suitable for production, but for teaching purposes, it exposes every detail that frameworks normally hide.
The Educational Value of Hand-Written Backpropagation
Modern frameworks like PyTorch and TensorFlow fully automate gradient computation through autograd — a massive boost for engineering productivity, but one that robs beginners of the chance to understand how the chain rule propagates through a network.
This project insists on manually deriving and implementing every gradient computation step using pure NumPy, meaning learners can read the backpropagation code line by line and understand exactly how weight updates happen. The author also implements several common training techniques:
- SGD with momentum: stochastic gradient descent with momentum
- L2 regularization and Dropout: two approaches to preventing overfitting
- Cosine decay: a learning rate scheduling strategy
- Four activation functions: for comparing how different nonlinearities affect training
On the full MNIST training set, this hand-written model achieves approximately 98.5% accuracy. While that falls short of deep convolutional networks, it's more than enough to validate correctness and usefulness for a pure NumPy MLP — and it shows students that even a basic model can achieve solid results.
Cosine decay is a scheduling strategy that gradually reduces the learning rate from its initial value toward zero following a cosine curve. Compared to fixed learning rates or step decay, its advantage lies in a smooth decay process: the learning rate decreases slowly early in training, giving the model ample time to explore the parameter space, then accelerates toward the end to help fine-tune convergence. In practice, this effectively prevents the model from oscillating around the optimum due to an overly large learning rate in the later stages. Implementing cosine decay by hand in this project means learners can directly observe the exact learning rate value at each epoch, rather than simply passing a scheduler name to a framework and letting everything happen automatically.
Real-Time Visualization of the Training Process
The core highlight of this tool is bringing all the key metrics of the training process into a graphical interface. During training, users can simultaneously observe:
- Loss changes per mini-batch and per epoch
- Gradient norms for each layer, along with the percentage of "dead" neurons
- Weight distributions — comparing the current state against initialization
- Receptive field visualizations for the first layer
These metrics normally require extra code or tools like TensorBoard to observe, but here they're integrated into a single interface. In particular, the real-time display of gradient norms and dead neuron ratios gives learners an intuitive view of how classic phenomena like vanishing gradients and neuron death (e.g., the dying ReLU problem) actually occur. The comparison of weight distributions against their initial state also makes it tangible what training actually changes.
Dimensionality Reduction Analysis and Error Diagnosis
The project includes built-in PCA and t-SNE dimensionality reduction analysis — also implemented in NumPy — allowing layer-by-layer inspection of how the test set is distributed in feature space.
A particularly clever design: for each misclassified sample, the interface draws a line connecting it to the cluster of the digit it was confused with. This visualization makes "why did the model get this wrong" immediately clear. If a large number of 4s are connected to the 9 cluster, for example, learners instantly understand that these two digits are genuinely close in the feature space the network has learned.
Combined with the layer-by-layer t-SNE display, users can also observe how different classes are gradually "pulled apart" as data propagates forward through the network, becoming increasingly linearly separable. This is tremendously helpful for understanding the nature of representation learning in deep networks.
PCA (Principal Component Analysis) and t-SNE are two dimensionality reduction methods that compress high-dimensional data into two or three dimensions for visualization. PCA is a linear method that projects data by finding the directions of maximum variance — fast to compute but limited in its ability to capture nonlinear structure. t-SNE (t-distributed Stochastic Neighbor Embedding) is a nonlinear method that excels at preserving local neighborhood relationships, clustering similar samples together, and is currently one of the most widely used tools for visualizing intermediate layer features in neural networks. In classification tasks, observing t-SNE results layer by layer makes it visually clear that features in shallow layers tend to be intermixed, while as depth increases, sample points of different classes gradually separate into distinct clusters — a direct illustration of how deep networks learn disentangled representations.
Robustness Testing and the Neuron "Laboratory"
Beyond training and dimensionality reduction analysis, the tool offers two advanced modules.
Robustness curves: These measure how model accuracy changes under noise and rotation perturbations, while also providing a confidence threshold slider that shows the trade-off between coverage and accuracy. This helps learners understand how the model behaves on inputs that deviate from the training distribution, and how to balance precision versus recall by setting a confidence threshold.
Neuron Laboratory: This is the most exploratory module. Users can:
- Ablate or scale individual neurons
- Prune neurons
- Inject noise into weights
- Adjust the softmax temperature
After each operation, the test accuracy updates immediately. This instant feedback transforms abstract questions like "which parts of the network matter" into hands-on experiments. Students can literally switch off a neuron and see what happens, building an intuitive sense of network redundancy and interpretability.
Softmax temperature is a parameter that controls how "sharp" or "flat" the probability distribution output by the softmax function is. Standard softmax converts the final layer's logits into probabilities; the temperature parameter T reshapes this distribution by dividing the logits by T. As T approaches 0, the probability of the top class approaches 1, making the model extremely "confident"; when T is greater than 1, the probability distribution becomes flatter, making the model appear more "uncertain." Adjusting the temperature in the Neuron Laboratory gives learners an intuitive feel for how model confidence and predicted probabilities don't necessarily reflect true accuracy — and also lays groundwork for understanding the role of temperature in more advanced topics like knowledge distillation and adversarial examples.
Who Should Use It
This project is not a production-grade solution chasing performance — its value lies entirely in education and insight. For the following groups, it may be an ideal learning or teaching aid:
- Self-learners who want to understand the underlying mechanics of backpropagation
- Students in high school or introductory university ML courses
- Teachers who want to visually demonstrate network training in the classroom
The author has explicitly invited feedback from educators on Reddit, indicating the project is still being actively refined. For anyone tired of treating frameworks as black boxes and wanting to truly see how neural networks operate internally, this kind of from-scratch, highly visual tool offers a level of transparency that no framework abstraction can provide. Interested readers can visit the GitHub repository to explore the source code and learn how to run it.
Related articles

Random Pruning of the DPO Computation Graph: 1.4x Training Speedup and Lower Peak Memory
DPO training too slow and memory-hungry? This paper proposes a random pruning framework for the DPO computation graph, sampling independently across position, sequence, and branch dimensions; branch pruning achieves a 1.426x step-time speedup and cuts training time by about 30%, with in-depth attribution of memory and time gains.

Why Does JEPA Underperform MLM in Longitudinal EHR Representation Learning?
New study compares JEPA and MLM for longitudinal EHR representation learning on MIMIC-IV: three JEPA variants train stably without collapse but underperform MLM; target size, not heterogeneity, drives prediction error.

Transfer Learning + Visible Light Communication: A New Approach to Energy-Efficient Indoor Positioning
A study proposes a transfer learning-based visible light communication indoor positioning method, achieving 47% accuracy improvement on the BOSCH factory dataset, 67.5% model efficiency under high noise, and introducing the ME composite metric for energy-efficient positioning in energy-constrained industrial IoT scenarios.