Topic guide · 6 recordings · 15 verbatim quotes

Andrej Karpathy on Backpropagation

Karpathy treats backpropagation as the practical chain rule on computational graphs: a general mechanism for getting exact gradients efficiently and using them to train neural networks.

In short
  • Backpropagation is repeated chain rule through a computational graph, not one giant symbolic derivative.
  • It is more general than neural nets because a neural net is just a mathematical expression.
  • Autograd systems work by storing local derivative rules during the forward pass and applying them in reverse.
  • Good training depends not just on having backprop, but on healthy activations, gradients, and sensible optimization.
  • The same backprop ideas scale from tiny scalar demos like micrograd to large models and sequence models.
Watch: Karpathy on backpropagationThe key moments, back to back, in his own words
4 moments · 3 min
1 / 4
“Micrograd is basically an autograd engine. Autograd is short for automatic gradient, and really what it does is it implements backpropagation. Now, backpropagation is this algorithm that allows you to efficiently evaluate the gradient of some kind of a loss function with respect to the weights of a neural network, and what that allows us to do then is we can iteratively tune the weights of that neural network to minimize the loss function and therefore improve the accuracy of the network. So backpropagation would be at the mathematical core of any modern deep neural network library, like say PyTorch or JAX. So the functionality of micrograd is, I think, best illustrated by an example, so…”
Educational talk, 2021-11 · 0:44

Backprop is chain rule made operational

Karpathy’s core framing is simple: backpropagation is the chain rule applied repeatedly over a computation graph. Instead of deriving one huge formula for an entire network, you break the computation into small pieces and propagate gradient information backward through those pieces. The key move is local: each operation contributes its own derivative, and the gradient is passed through by multiplication.12

He also presents this as the engine underneath modern deep learning. In his view, backprop is what lets you efficiently compute how a loss changes with respect to weights, which is exactly what you need to improve a model by iterative updates. That is why autograd sits at the mathematical core of libraries such as PyTorch or JAX.23

Andrej Karpathy, Educational talk, 2021-11
“Micrograd is basically an autograd engine. Autograd is short for automatic gradient, and really what it does is it implements backpropagation. Now, backpropagation is this algorithm that allows you to efficiently evaluate the gradient of some kind of a loss function with respect to the weights of a neural network, and what that allows us to do then is we can iteratively tune the weights of that neural network to minimize the loss function and therefore improve the accuracy of the network. So backpropagation would be at the mathematical core of any modern deep neural network library, like say PyTorch or JAX. So the functionality of micrograd is, I think, best illustrated by an example, so…”
Educational talk, 2021-11 · full transcript →

Neural networks are not special cases; they are expressions

A recurring Karpathy idea is that backprop is broader than neural networks because neural networks themselves are just mathematical expressions. That framing matters because it removes the mystery: if you can write the computation as a graph of elementary operations, you can differentiate it by traversing the graph backward.42

This is why he likes teaching from scalar expression graphs first. Tiny examples make the mechanics visible before any matrix algebra hides them. Once the learner understands addition, multiplication, and nonlinearities locally, the jump to full neural networks becomes a change in scale rather than a change in principle.51

Autograd works because each operation knows its local derivative

Karpathy’s micrograd teaching style emphasizes that an autograd engine can be built from very small pieces. Each node in the graph performs a forward computation and also knows how to contribute its piece of the backward computation. For nonlinearities, that means encoding the local derivative rule explicitly, such as tanh’s backward rule.35

This gives a concrete mental model for the backward pass. You do not need to imagine a magical global derivative appearing from nowhere; gradients are assembled from local rules attached to the graph. That is the intuition he uses to connect first-principles teaching to the behavior of full deep learning libraries.32

Andrej Karpathy, Educational talk, 2021-11
“…the backward pass for tanh is one minus t squared…”
Educational talk, 2021-11 · full transcript →

Training is a loop of forward, backward, and update

Karpathy presents backprop as one stage in a repeated optimization cycle: compute outputs and loss, run backward to get gradients, then update parameters. The cycle is the practical heartbeat of neural network training.62

He also stresses that optimization quality matters. Learning rate choices and schedules affect whether those gradients turn into useful progress, and a shrinking learning rate can help refine the fit later in training. Backprop gives the direction, but training success still depends on how you use that signal.78

Bad activations can make backprop useless

Karpathy does not treat gradients as automatically healthy just because backprop computes them. He shows that poor initialization can make a network start off confidently wrong, producing inflated losses before learning even gets going.910

He also emphasizes that nonlinearities can damage gradient flow. Saturated activations can squash gradients and stall learning, which is why inspecting activations and gradients is a practical debugging skill, not an optional theory exercise. His activation-function discussion also points to why some choices, such as ReLU, became popular partly for optimization behavior.9

The same backprop ideas scale to language models and sequence models

Karpathy uses backprop as a throughline from toy models to modern systems. In small language models, learned embeddings let the model share statistical structure and generalize, and those embeddings are learned by gradient-based training.11

In recurrent models, the same machinery extends over time: sequence models process variable-length inputs and outputs, and training works by propagating gradients through the repeated computation across time steps. At larger scale, models like GPT-2 are still collections of weights and biases inside a Transformer, trained with the same basic gradient-based logic even if the implementation is much bigger.12131415

Andrej Karpathy, CS231n Winter 2016 Lecture 10, 2017
“We can actually operate over sequences: sequences at the input/output or both at the same time.”
CS231n Winter 2016 Lecture 10, 2017 · full transcript →

Karpathy on backpropagation, in his own words

“Micrograd is basically an autograd engine. Autograd is short for automatic gradient, and really what it does is it implements backpropagation. Now, backpropagation is this algorithm that allows you to efficiently evaluate the gradient of some kind of a loss function with respect to the weights of a neural network, and what that allows us to do then is we can iteratively tune the weights of that neural network to minimize the loss function and therefore improve the accuracy of the network. So backpropagation would be at the mathematical core of any modern deep neural network library, like say PyTorch or JAX. So the functionality of micrograd is, I think, best illustrated by an example, so…”
Educational talk, 2021-11answer page →
“…the correct thing to do is to multiply them…”
CS231n Winter 2016 Lecture 4
“…the backward pass for tanh is one minus t squared…”
Educational talk, 2021-11

Where to watch

  1. Andrej Karpathy on Backpropagation: Computational Graphs and Gradients2016 · 80 min · full transcriptBest concise explanation of backprop as local derivatives and chain rule through computational graphs.
  2. Andrej Karpathy on Neural Networks: Building Micrograd2021 · 146 min · full transcriptBest first-principles walkthrough of building autograd and seeing backprop work step by step.
  3. Andrej Karpathy on Activations & Gradients: BatchNorm2021 · 116 min · full transcriptShows how backprop interacts with initialization, activation saturation, and gradient health in practice.
  4. Andrej Karpathy on Recurrent Neural Networks: LSTMs and Captioning2017 · 70 min · full transcriptExtends the idea to sequences and shows how gradients accumulate through repeated computation over time.
  5. Andrej Karpathy on GPT-2 Reproduction: Rebuilding 124M From Scratch2022 · 241 min · full transcriptUseful for seeing how the same gradient-based training ideas underpin a full Transformer-scale implementation.

Questions people ask

Go deeper · free courseThe Andrej Karpathy Course13 chapters on everything Karpathy taught, with a certificate at the end.Start learning →

Sources

Every quote above, word for word from the transcripts. Numbers match the text.

1
“…the correct thing to do is to multiply them…”
CS231n Winter 2016 Lecture 4
2
“Micrograd is basically an autograd engine. Autograd is short for automatic gradient, and really what it does is it implements backpropagation. Now, backpropagation is this algorithm that allows you to efficiently evaluate the gradient of some kind of a loss function with respect to the weights of a neural network, and what that allows us to do then is we can iteratively tune the weights of that neural network to minimize the loss function and therefore improve the accuracy of the network. So backpropagation would be at the mathematical core of any modern deep neural network library, like say PyTorch or JAX. So the functionality of micrograd is, I think, best illustrated by an example, so…”
Educational talk, 2021-11answer page →
3
“…micrograd is basically an autograd engine.”
Educational talk, 2021-11
4
“Even neural networks are just a mathematical expression.”
Educational talk, 2021-11
5
“…the backward pass for tanh is one minus t squared…”
Educational talk, 2021-11
6
“…forward, backward, update; forward, backward, update.”
CS231n Winter 2016 Lecture 4
7
“You'll notice that in the update here, the learning rate is scaled as a function of number of iterations, and it shrinks. This is something called learning rate decay. So, in the beginning, you have a high learning rate, and as the network sort of stabilizes near the end, you bring down the learning rate to get some of the fine details in the end. And in the end, we see the decision surface of the neural net, and we see that it learns to separate out the red and the blue area based on the data points.”
Educational talk, 2021-11answer page →
8
“Actually, have confidence that our learning rate is set very well, that our learning rate decay, which we just do at random, is set very well. And, um, so the optimization here is kind of suspect, to be honest, and this is not how you would do it typically in production. In production, you would create parameters or hyperparameters out of all these settings, and then you would run lots of experiments and see whichever ones are working well for you. Okay. So we have 2.17 now and 2.2. Okay. So you see how the training and the validation performance are starting to slightly, slowly depart. So maybe we're getting the sense that the neural net is getting good enough or that number of parameters is large.”
Building makemore Part 2: MLP, online lecture, 2020answer page →
9
“…the network is very confidently wrong…”
Building makemore Part 3 lecture, 2021
10
“At initialization, we have no reason to believe any characters to be much more likely than others, and so we'd expect that the probability distribution that comes out initially is a uniform distribution assigning about equal probability to all the 27 characters. So basically, what we'd like is the probability for any character would be roughly 1 over 27. That is the probability we should record, and then the loss is the negative log probability. So let's wrap this in a tensor and then we can take the log of it, and then the negative log probability is the loss we would expect, which is 3.29, much, much lower than 27.”
Building makemore Part 3 lecture, 2021answer page →
11
“…you can transfer knowledge through that embedding, and you can generalize in that way.”
Building makemore Part 2: MLP, online lecture, 2020
12
“We can actually operate over sequences: sequences at the input/output or both at the same time.”
CS231n Winter 2016 Lecture 10, 2017
13
“This is what allows us to process, you know, variably sized inputs.”
CS231n Winter 2016 Lecture 10, 2017
14
“…everything here is just the other weights and biases and everything else of this Transformer…”
OpenAI / online talk, 2022-11
15
“…we can actually match the 124 million parameter checkpoints of GPT-2…”
OpenAI / online talk, 2022-11

How this guide was made: drafted with AI from the full transcripts of the recordings cited, then checked: every quotation must match a transcript word for word and be the speaker's own words, and an independent review gates accuracy. Methodology and corrections.

All 6 recordings of Andrej Karpathy on Backpropagation

Search every transcript
Open the full search page →