How to Visualize a Neural Network | QuantumSketch
Visualize a neural network as layers of nodes connected by weighted edges, with data flowing left to right and brightening connections showing what it learned.
Visualize a neural network as layers of nodes connected by weighted edges, with data flowing left to right; brightening or thickening connections show what the network has learned. Watching a number travel and combine demystifies the whole thing.
The forward pass, beat by beat
- Draw the layers โ input, one or two hidden layers, output โ as columns of circles.
- Feed an input โ e.g. pixels of a handwritten digit light up the input layer.
- Flow forward โ each connection lights up as it carries weight ร value.
- Sum + activate โ each node sums its inputs and applies an activation (ReLU/sigmoid).
- Read the output โ the brightest output node is the prediction.
Adding the learning loop
| Phase | What you animate | |---|---| | Forward pass | Numbers flow to a prediction | | Loss | Compare prediction to truth | | Backprop | Error flows backward | | Update | Weights nudge (gradient descent) |
Repeat over examples and the connections settle into a pattern that classifies correctly. That's learning, made visible.
Why this beats a static diagram
A textbook diagram shows the architecture but hides the motion โ the weighted sums, the activation, the weights changing. Animation shows the verbs, not just the nouns. This is the core idea behind the deep-learning revolution.
Manim building blocks
Circle for nodes, Line for connections (stroke_width โ weight), VGroup to organize layers, and color/opacity changes to show signal flow. A ValueTracker can drive the training iterations.
The prompt
"Show a small neural network classifying a digit: input, two hidden layers, output. Animate the forward pass lighting up connections, then weights updating as it learns."
โ Render it at quantumsketch.app. Related: Visualize Gradient Descent.
Written by Shihab Shahriar Antor ยท Shahriar Labs
FAQ
Q.What's the clearest way to animate how a neural network works?
Show layers of circular nodes connected by lines, with a number flowing through. Draw an input layer, one or two hidden layers, and an output layer. Animate an input โ say the pixels of a handwritten digit โ entering the first layer, then light up each connection as its weighted value passes forward, through an activation function, to the next layer, until the output layer produces a prediction. This forward-pass animation makes the abstract phrase 'the network computes a weighted sum and applies an activation' concrete: you literally watch numbers travel and combine.
Q.How do I animate a neural network learning, not just running?
Add the training loop on top of the forward pass. After the forward pass produces a prediction, animate the error being measured against the correct answer, then show the weights nudging โ connection thicknesses or colors changing โ via backpropagation and gradient descent. Repeating this over several examples shows the connections settling into a pattern that classifies correctly. Describe 'a small network learning to classify digits, showing forward pass, error, and weights updating' as a prompt and QuantumSketch renders it as a narrated Manim animation.