Brains › Andrej Karpathy › Rules › Understand the backward passConfirmed · 1 videos Understand the backward pass Learn how gradients actually flow, practice backpropagation by hand, and monitor activation and gradient statistics instead of trusting autograd blindly.
He calls backpropagation a leaky abstraction. Saturated sigmoids, dead ReLUs, exploding RNN gradients and clipping bugs all come from backward-pass behavior that frameworks conceal. Manual practice and statistical diagnostics give practitioners the intuition to debug and to innovate.
Based on Andrej Karpathy's public content. Not affiliated with or endorsed by Andrej Karpathy.
What following it looks like Writes the backward pass for each layer manually, without calling autograd Sums gradient contributions at reused nodes and resets gradients before every backward pass Plots activation and gradient histograms to catch saturation or improper scaling Checks whether ReLU units ever fire across the training set Evidence · 12 quotes from 1 video Each quote was matched word for word against the transcript. Tap the time to hear it.
“that's what back propagation is is just a recursive application of chain rule backwards through the computation graph”
50:59 always so we just go through and recursively
51:01 so we just go through and recursively multiply on the local derivatives and
51:04 multiply on the local derivatives and that's what back propagation is is just
51:05 that's what back propagation is is just a recursive application of chain rule
51:08 a recursive application of chain rule backwards through the computation graph
“if you can write the local gradients you can chain the gradient and you can continue back propagation”
1:39:19 that little operation it doesn't matter what that operation is
1:39:21 what that operation is and how composite it is
1:39:23 and how composite it is if you can write the local gradients you
1:39:24 if you can write the local gradients you can chain the gradient and you can
1:39:25 can chain the gradient and you can continue back propagation so the design
“as long as you can do forward pass and the backward pass of that little operation it doesn't matter what that operation is”
1:39:10 matters is we have some kind of inputs and some kind of an output and this
1:39:11 and some kind of an output and this output is a function of the inputs in
1:39:13 output is a function of the inputs in some way and as long as you can do
1:39:14 some way and as long as you can do forward pass and the backward pass of
1:39:16 forward pass and the backward pass of that little operation it doesn't matter
“the design of what those functions are is completely up to”
1:39:23 and how composite it is if you can write the local gradients you
1:39:24 if you can write the local gradients you can chain the gradient and you can
1:39:25 can chain the gradient and you can continue back propagation so the design
1:39:28 continue back propagation so the design of what those functions are is
1:39:30 of what those functions are is completely up to you
“we just accumulate those gradients and that fixes the issue”
1:26:25 detail backward it will deposit its own gradients and then those gradients
1:26:28 gradients and then those gradients simply add on top of each other and so
1:26:30 simply add on top of each other and so we just accumulate those gradients and
1:26:31 we just accumulate those gradients and that fixes the issue okay now before we
1:26:34 that fixes the issue okay now before we move on let me actually do a bit of
“the solution there is basically that we have to accumulate these gradients these gradients add”
1:25:19 and the solution here if you look at the multivariate case of the chain rule
1:25:22 the multivariate case of the chain rule and its generalization there
1:25:23 and its generalization there the solution there is basically that we
1:25:26 the solution there is basically that we have to accumulate these gradients these
1:25:28 have to accumulate these gradients these gradients add
“we need to accumulate those gradients”
1:25:30 gradients add and so instead of setting those
1:25:32 and so instead of setting those gradients
1:25:34 gradients we can simply do plus equals we need to
1:25:37 we can simply do plus equals we need to accumulate those gradients
1:25:39 accumulate those gradients plus equals plus equals
“we just go through and recursively multiply on the local derivatives”
50:56 what the local derivatives are and we just multiply them onto the derivative
50:58 just multiply them onto the derivative always
50:59 always so we just go through and recursively
51:01 so we just go through and recursively multiply on the local derivatives and
51:04 multiply on the local derivatives and that's what back propagation is is just
“this is really done so that you understand and refactor out back propagation and chain rule and understanding of neurologic training”
5:52 to not have to deal with these n-dimensional tensors that you would use
5:54 n-dimensional tensors that you would use in modern deep neural network library so
5:56 in modern deep neural network library so this is really done so that you
5:58 this is really done so that you understand and refactor out back
6:00 understand and refactor out back propagation and chain rule and
“but none of the math changes this is done purely for efficiency”
6:04 understanding of neurologic training and then if you actually want to train
6:06 and then if you actually want to train bigger networks you have to be using
6:08 bigger networks you have to be using these tensors but none of the math
6:09 these tensors but none of the math changes this is done purely for
6:11 changes this is done purely for efficiency we are basically taking scale
“you can understand how things work uh at the fundamental level and then you can speed it up later”
6:38 useful to be dealing with tensors from scratch uh and i think and that's why i
6:40 scratch uh and i think and that's why i fundamentally wrote micrograd because
6:42 fundamentally wrote micrograd because you can understand how things work uh at
6:44 you can understand how things work uh at the fundamental level and then you can
6:46 the fundamental level and then you can speed it up later okay so here's the fun
“the only thing that matters is that we know how to differentiate through any one function”
58:24 points of abstraction they can be complicated functions but they can be
58:26 complicated functions but they can be also very very simple functions like a
58:27 also very very simple functions like a plus and it's totally up to us the only
58:30 plus and it's totally up to us the only thing that matters is that we know how
58:31 thing that matters is that we know how to differentiate through any one
Linked topics