Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Micrograd β€” Study Walkthrough

Personal study of Andrej Karpathy's micrograd β€” a tiny autograd engine built from scratch.Personal notes and understanding written inline as comments.

What is Micrograd?

Micrograd is a scalar-valued autograd engine that implements backpropagation over a dynamically built computational graph. It's the core mechanism behind every deep learning framework (PyTorch, TensorFlow) β€” just stripped down to ~100 lines of Python.

What I Studied

  • Value class β€” how every scalar operation builds a computation graph
  • Forward pass β€” how values flow through operations (+, *, tanh, relu)
  • Backward pass β€” how gradients flow back through the graph via chain rule
  • Backpropagation β€” manual derivation of gradients for each operation
  • MLP architecture β€” Neuron β†’ Layer β†’ MLP built on top of the autograd engine
  • Training loop β€” forward pass, loss computation, zero_grad, backward, update

Key Insight

Every operation (add, multiply, tanh) not only computes the output but also stores how to compute its own gradient. When .backward() is called, it walks the graph in reverse topological order and applies chain rule automatically. This is exactly how PyTorch works internally.

Notebook

The main notebook (micrograd_walkthrough.ipynb) contains:

  • Full implementation walkthrough
  • Inline personal notes and understanding at each step
  • Visualization of computational graphs
  • MLP training example

Stack

Part of

This repo is part of my study series following Andrej Karpathy's Neural Networks: Zero to Hero course.

Repo Topic Status
micrograd-study Autograd engine, backprop βœ… Done
makemore-study Character-level LM, bigram model πŸ”„ In progress

About

Micrograd implementation from Andrej Karpathy

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages