@ProfTomYeh: Backpropagation by hand ~ 11 steps walkthrough below Backpropagation is the algorithm that actually trains a neural net…
Summary
A walkthrough of backpropagation by hand through a 3-layer network using matrix multiplication, showing all 11 steps from gradients to weight updates.
View Cached Full Text
Cached at: 07/20/26, 11:33 PM
Backpropagation by hand ~ 11 steps walkthrough below
Backpropagation is the algorithm that actually trains a neural network, and it is where most people stop following along. It is not calculus you cannot do. It is matrix multiplication, working backward, one layer at a time.
So I drew and calculated one entirely by hand.
Goal: push the loss gradient back through a 3-layer network and land on a new value for every weight and bias.
= 1. Given =
A 3-layer perceptron, an input X, predictions Ypred = [0.5, 0.5, 0], and the truth Ytarget = [0, 1, 0].
= 2. Backprop gradient cells =
Let us draw empty cells for every gradient we are about to compute. The shape of the answer comes first.
= 3. Layer 3 softmax =
We get dL/dz3 straight from Ypred minus Ytarget = [0.5, -0.5, 0]. No chain rule needed, and that shortcut is the whole reason softmax and cross-entropy are paired.
= 4. Layer 3 weights and biases =
Let us multiply dL/dz3 by [a2 | 1]. One multiplication gives the gradient for W3 and b3 together.
= 5. Layer 2 activations =
We multiply dL/dz3 by W3 to get dL/da2. The gradient moves back across a layer the same way the signal moved forward.
= 6. Layer 2 ReLU =
Let us pass it through the gate: keep the gradient where the activation was positive, zero it everywhere else.
= 7. Layer 2 weights and biases =
We multiply dL/dz2 by [a1 | 1]. The same figure as step 4, one layer up.
= 8. Layer 1 activations =
Let us multiply dL/dz2 by W2.
= 9. Layer 1 ReLU =
We apply the same gate again, now on a1.
= 10. Layer 1 weights and biases =
Let us multiply dL/dz1 by [x | 1], and every weight in the network now has a gradient.
= 11. Update =
We subtract, and the network has learned. In practice a learning rate scales this step.
The gradients: dL/dz3 = [0.5, -0.5, 0] dL/da1 = [1, -2, 2, -1] dL/dz1 = [0, -2, 2, -1]
The takeaway: matrix multiplication is all you need. Just like the forward pass, backpropagation is matrix multiplications end to end. You can do every one by hand, slowly and imperfectly, which is exactly why a GPU’s ability to do them fast mattered so much to deep learning.
Save this post!
Similar Articles
@ProfTomYeh: Transformer by hand ~ 6 steps walkthrough below Studying the Transformer architecture is like opening up the engine hoo…
A step-by-step walkthrough explaining the core components of the Transformer architecture by manually calculating attention weighting and feed-forward networks to illustrate how Transformers function.
@antoniolupetti: "Computing Neural Network Gradients" is a clear introduction to the mathematics behind backpropagation and gradient com…
Stanford CS224N course notes provide a clear introduction to the mathematics of backpropagation and gradient computation in neural networks, covering chain rule, computational graphs, and vectorized derivatives.
@ProfTomYeh: Autoencoder by hand interactive diagram. Open https://byhand.ai/autoencoder ~ Prof. Tom Yeh
Prof. Tom Yeh shares an interactive diagram for learning about autoencoders, part of his 'AI by Hand' series focused on multi-layer perceptrons.
@ProfTomYeh: Switch Transformer by hand ~ 13 steps walkthrough below The Switch Transformer, by Fedus, Zoph, and Shazeer in 2022, is…
A 13-step visual walkthrough explaining how the Switch Transformer works, covering sparse mixture-of-experts routing and why models like GPT-4, Claude, DeepSeek-V3, and Kimi use this architecture to stay efficient.
@DanKornas: Neural nets are easier to understand when you can see the math cell by cell. ai-by-hand-excel is a collection of Excel …
ai-by-hand-excel is an open-source collection of Excel workbooks that teach AI concepts like neural networks, backpropagation, and transformers by letting users inspect the math cell by cell, making model internals more intuitive.