The spelled-out intro to neural networks and backpropagation: building micrograd
Watch on YouTubeKarpathy 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.
- Neural networks can be represented as mathematical expressions whose inputs include data and trainable parameters. - A gradient measures how a tiny change in one value locally affects the final output or loss. - Backpropagation traverses a computation graph backward and repeatedly multiplies upstream gradients by local derivatives. - Gradients from multiple uses or branches of a value must be accumulated rather than overwritten. - A neuron computes a weighted sum plus a bias and then applies a nonlinearity; layers collect independent neurons, and an MLP sequences layers. - Training minimizes a loss by repeatedly running a forward pass, zeroing gradients, backpropagating, and updating parameters opposite the loss gradient.
Based on Andrej Karpathy's public content. Not affiliated with or endorsed by Andrej Karpathy.
Supports these rules
Quotes from this video
“literally a layer is just a list of neurons”
“what is a layer of neurons it's just it's just a set of neurons evaluated independently”
“we're going to take a list of an outs and this list defines the sizes of all the layers that we want in our mlp”
“that's what back propagation is is just 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”
“as long as you can do forward pass and the backward pass of that little operation it doesn't matter what that operation is”
“the design of what those functions are is completely up to”
“we just accumulate those gradients and that fixes the issue”
“the solution there is basically that we have to accumulate these gradients these gradients add”
“we need to accumulate those gradients”
“we just go through and recursively multiply on the local derivatives”
“this is really done so that you understand and refactor out back propagation and chain rule and understanding of neurologic training”
“but none of the math changes this is done purely for efficiency”
“you can understand how things work uh at the fundamental level and then you can speed it up later”
“the only thing that matters is that we know how to differentiate through any one function”
“you forgot to zero grad before that backward”
“working with neural nets is sometimes tricky because uh you may have lots of bugs in the code and uh your network might actually work”