Manual backprop and gradient checking
Derive and verify gradients by hand to build intuition.
Based on Andrej Karpathy's public content. Not affiliated with or endorsed by Andrej Karpathy.
Steps
- Write the local derivative for each operation
- Chain gradients backward through the graph, accumulating them at branches
- Compare against finite differences or PyTorch
- Reset gradients between iterations
Covered in
The spelled-out intro to neural networks and backpropagation: building micrograd
Karpathy teaches neural-network training from first principles by building micrograd, a scalar-valued automatic-gradient engine, and then using it to construct and train a multilayer perceptron. He explains derivatives as local sensitivities, backpropagation as recursive application of the chain rule through a computation graph, and training as repeated forward, backward, gradient-reset, and parameter-update steps.
GitHub · micrograd: A tiny scalar-valued autograd engine and a neural net library on top of it with PyTorch-like API
This README presents micrograd, a tiny scalar-valued autograd engine (about 100 lines) implementing backpropagation over a dynamically built DAG, plus a ~50-line neural net library with a PyTorch-like API. Karpathy shows that operating on individual scalars is enough to build and train deep neural nets, and he points to microgpt as a single-file complete GPT algorithm where everything else is just efficiency. He frames it as potentially useful for education.
Building makemore Part 4: Becoming a Backprop Ninja
This source describes a lesson in which Karpathy takes a 2-layer MLP with BatchNorm from a previous video and backpropagates through it manually, without using PyTorch autograd's loss.backward(). He walks through each component in turn, from the cross entropy loss back to the embedding table, so that learners build intuition for how gradients flow. The provided text is a short, truncated description, so only its outline can be noted.
Yes you should understand backprop | by Andrej Karpathy | Medium
Karpathy teaches that backpropagation is a leaky abstraction whose mechanics must be understood to build and debug neural networks effectively. He demonstrates how backward-pass behavior causes saturated sigmoids, dead ReLUs, unstable RNN gradients, and a subtle DQN clipping bug, then recommends intuition-focused study and manual implementation.