Save this video free

Building makemore Part 4: Becoming a Backprop Ninja

Andrej Karpathy · 1:55:24 · Watch on YouTube

These notes were made with YouTube Collector. Paste any YouTube link and get the same: a summary, chapters and a searchable transcript.

Overview

Andrej Karpathy's "Building makemore Part 4" details the manual implementation of backpropagation for a two-layer neural network, moving beyond PyTorch's autograd. This "Backprop Ninja" exercise covers deriving gradients for operations like cross-entropy loss, batch normalization, linear layers, and embeddings, emphasizing the importance of understanding internals for debugging and optimization. The lecture culminates in a fully manual training loop, demonstrating that complex neural networks can be trained without relying on automatic differentiation frameworks.

Key takeaways

Chapters

0:00 Motivation: The Need for Manual Backpropagation
0:37 Why Manual Backprop is Crucial
5:00 Historical Examples of Manual Backpropagation
11:46 Setting Up the Manual Backprop Notebook
13:18 Parameter Initialization for Debugging
15:05 Manual Backpropagation: D_log_probs
31:46 Manual Backpropagation: D_probs
34:19 Manual Backpropagation: D_counts
35:41 Manual Backpropagation: D_count_sum_inv
37:04 Manual Backpropagation: D_count_sum
43:46 Manual Backpropagation: D_counts (Second Pass)
53:49 Manual Backpropagation: D_normal_logits
55:14 Manual Backpropagation: D_logits (Softmax Branch)
1:03:56 Understanding Logit Maxima's Role
1:05:08 Manual Backpropagation: D_logits (Max Index Branch)
1:09:04 Manual Backpropagation: Linear Layer (Layer 2)
1:28:56 Manual Backpropagation: Tanh Activation
1:31:59 Manual Backpropagation: Batch Normalization
1:48:40 Batch Normalization: Bias Correction Discussion
1:55:03 Manual Backpropagation: Linear Layer (Layer 1)

Keep these chapters and the full searchable transcript in your own library.

Transcript excerpt

0:00 hi everyone so today we are once again continuing our implementation of make more now so far we've come up to here montalia perceptrons and our neural net looked like this and we were implementing this over the last few lectures now I'm sure everyone is very excited to go into recurring neural networks and all of their variants and how they work and the diagrams look cool and it's very exciting and interesting and we're going to get a better result but unfortunately I think we have to remain here for one more lecture and the reason for that is we've already trained this multilio perceptron right and we are getting pretty good loss and I think we have a pretty decent understanding of the architecture and how it works but the line of code here that I take an issue with is here lost up backward that is we are taking a pytorch auto grad and using it to calculate all of our gradients

0:46 along the way and I would like to remove the use of lost at backward and I would like us to write our backward pass manually on the level of tensors and I think that this is a very useful exercise for the following reasons I actually have an entire blog post on this topic but I'd like to call back propagation a leaky abstraction and what I mean by that is back propagation does doesn't just make your neural networks just work magically it's not the case they can just Stack Up arbitrary Lego blocks of differentiable functions and just cross your fingers and back propagate and everything is great things don't just work automatically it is a leaky abstraction in the sense that you can shoot yourself in the foot if you do not understanding

This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.

Related notes

Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Andrej Karpathy.

Want the full transcript?

Save this video in YouTube Collector to get its complete searchable transcript, your own AI summaries, and a library that keeps every video you collect in one place.