Skip to content
0:00 / 0:00

#backpropagation#neuralnetworks#micrograd

The spelled-out intro to neural networks and backpropagation: building micrograd

Andrej Karpathy

1.7M subscribers • 6 videos on Hallway

YouTube

Beginner. No background in the topic needed.

4.3M views4 years ago17 recommendations

AI and machine learningComputer scienceNeural networks and deep learningMath for machine learningAlgorithms

Andrej Karpathy builds a tiny autograd engine in Python, explaining backpropagation and neural network training step by step.

This is the most step-by-step spelled-out explanation of backpropagation and training of neural networks. It only assumes basic knowledge of Python and a vague recollection of calculus from high school. Links: - micrograd on github: github.com/karpathy/micrograd - jupyter notebooks I built in this video: github.com/karpathy/nn-zero-to-hero/tree/master/lectures/mic… - my website: karpathy.ai - my twitter: twitter.com/karpathy - "discussion forum": nvm, use youtube comments below for now :) - (new) Neural Networks: Zero to Hero series Discord channel: discord.gg/3zy8kqD9Cp , for people who'd like to chat more and go beyond youtube comments Exercises: you should now be able to complete the following google collab, good luck!: colab.research.google.com/drive/1FPTx1RXtBfc4MaTkf7viZZD4U2F… Chapters: intro micrograd overview derivative of a simple function with one input derivative of a function with multiple inputs starting the core Value object of micrograd and its visualization manual backpropagation example #1: simple expression preview of a single optimization step manual backpropagation example #2: a neuron implementing the backward function for each operation implementing the backward function for a whole expression graph fixing a backprop bug when one node is used multiple times breaking up a tanh, exercising with more operations doing the same thing but in PyTorch: comparison building out a neural net library (multi-layer perceptron) in micrograd creating a tiny dataset, writing the loss function collecting all of the parameters of the neural net doing gradient descent optimization manually, training the network summary of what we learned, how to go towards modern neural nets walkthrough of the full code of micrograd on github real stuff: diving into PyTorch, finding their backward pass for tanh conclusion outtakes :)

Why it's here

17 people recommend this

What people say. Widely recommended as the absolute best, most intuitive introduction to backpropagation and the mathematical fundamentals of neural networks.

Geeeon Hacker News • Recommends

On “A step by step backpropagation example (2015)”

I recommend watching Andrej Karpathy's recent videos on backprop and neural nets. Makes it really simple and intuitive. The spelled-out intro to neural networks and backpropagation: link to this video Becoming a backprop ninja: link

ian0on Hacker News • Recommends

On “Andrej Karpathy Is Joining OpenAI Again”

For those who dont know, Andrej has a brilliant series of videos on youtube where he explores the basics of neural nets right up to transformer architecture through code. Starts here 0 and most recent is building GPT from scratch in code. link to this video

base698on Hacker News • Recommends

On “ChatGPT Explained: A Normie's Guide to How It Works”

The ChatGPT video by Karpathy is the last in a 7 video series. The one that really hit it home for me was the first video on MicroGrad 1. The second video builds on MicroGrad and is also great for understanding how a basic NN works. 1 link to this video

gavion Hacker News • Recommends

On “Deep Learning as Computational Graphs (2018)”

I highly recommend the video from karpathy link to this video - This explains the same idea spelled out in code. It really helped me understand the mathematical expression graph of neural networks. He uses graphviz to show the expressions and initially calculate gradients manually and then implement back propagation.

radqon Hacker News • Recommends

On “GPT4 is 8 x 220B params = 1.7T params”

Andrej Karpathy's "zero to hero" series 1 was how I learned the fundamentals of this stuff. It's especially useful because he explains the why and provides intuitive explanations instead of just talking about the what and how. Would recommend it if you haven't checked it out already. 1 link to this video

paulsmithon Hacker News • Recommends

On “Linear Algebra for Programmers”

Watch Karpathy's recent lectures. They're gold. Start here1 with micrograd2. It doesn't use linear algebra/matrices to start, but the principles are the same. The matrix multiplication is how the weights of the connections between neurons and the input values are combined (to form an activation value that then may lead to that neuron "firing" or not, depending on whether it passes some threshold function). We use matrices to model the connections between neurons - each row is a connection, and each column is a weight corresponding to an input. 1 link to this video 2 link

throwaway7783on Hacker News • Recommends

On “How linear regression works intuitively and how it leads to gradient descent”

In the same vein, Karpathy's video series "Neural Networks from zero to hero"0 touches upon a lot of this and intuitions as well. One of the best introductory series (even if you ignore the neural net part of it) and brushes on gradients, differentiation and what it means intuitively. 0 link to this video

jackdoeon Hacker News • Recommends

On “The Illusion of Thinking: Strengths and limitations of reasoning models [pdf]”

…odels by hand to get intuition for the signal flow, and building all kinds of smallish systems, e.g. how far can you push whisper, small qwen3, and kokoro to control your computer with voice? People think that deepseek/mistral/meta etc are democratizing AI, but its actually Karpathy who teaches us :) so we can understand them and make our own. 1 link to this video 2 link 3 link 4 link…

omrishnon Hacker News • Recommends

On “Deep dive into the small details of micrograd”

This blog post analyzes the code with an emphasis on the small details and ideas explored in Andrej Karpathy's awesome micrograd lecture. Link to the original lecture: link to this video I'd love to hear any thougts/reviews about the blog post.

jwitthuhnon Hacker News • Recommends

On “The Illustrated Transformer”

If you have 20 hours to spare I highly recommend this youtube playlist from Andrej Karpathy link to this video It starts with the fundamentals of how backpropagation works then advances to building a few simple models and ends with building a GPT-2 clone. It won't taech you everything about AI models but it gives you a solid foundation for branching out.

deracon Hacker News • Recommends

On “MinGPT: Minimal PyTorch re-implementation of GPT”

I love your approach and philosophy around programming. If anyone is unaware, Karpathy has a relatively small youtube channel he started a few weeks ago. link to this video

bialpioon Hacker News • Recommends

On “Let's build GPT: from scratch, in code, spelled out by Andrej Karpathy”

link to this video The entire series is at link , first video is literally from scratch (i.e. just Python, the only external dependency is for plotting graphs if I recall correctly).

tjvcon Hacker News • Recommends

On “Post-GPT Computing”

I think this is a good take. I hope to do the same. For the understanding part, Andrej Karpathy has a YouTube playlist that explains neural networks. I made a start on it today and found it quite accessible. link to this video

karpathyon Hacker News • Recommends

On “Llm.c – LLM training in simple, pure C/CUDA”

I wrote this, which might be a bit helpful: link But if you don't have the background, I'd recommend my YouTube videos, see the Zero To Hero playlist: link to this video

sprobertsonon Hacker News • Recommends

On “Ask HN: Calculus Refresher for AI/ML?”

imo linear algebra is the main thing to refresh yourself on, as most of NN is based on matrix multiplication. The calculus is mostly in the gradient descent which in practice is abstracted away, so having a few decades old understanding might be good enough. For practical implementation Andrej Karpathy has a good series of videos going over a lot of the concepts starting here link to this video

strangecastson Hacker News • Recommends

On “Ray Tracing in One Weekend”

Andrej Karpathy's guide to Micrograd - link to this video - is probably the closest equivalent, in that it covers the basic ideas of backpropagation and autodiff frameworks like PyTorch, and ends with an implementation of a very basic framework ( link ) you can train small neural networks in