A Python implementation of Andrej Karpathy’s micrograd — a minimal neural network and autograd engine built from scratch.
This project follows Karpathy’s YouTube tutorial "The spelled-out intro to neural networks and backpropagation" and serves as my learning exercise in understanding backpropagation, computational graphs, and building models without heavy frameworks.
- Minimal, clean Python code
Valueclass for scalar values with automatic differentiation- Basic operations: addition, multiplication, exponentiation, etc.
- Backpropagation from scratch
- Simple neural network implementation
my-micrograd/ │ ├── micrograd/ # Core engine │ ├── engine.py # Value class and backprop logic │ ├── nn.py # Simple neural network components │ ├── examples/ # Example usage scripts │ └── train.py # Small neural network training example │ ├── README.md # Project documentation └── requirements.txt # Dependencies (if any)
git clone https://github.com/<your-username>/my-micrograd.git
cd my-micrograd
pip install -r requirements.txt
from micrograd.engine import Value
a = Value(2.0)
b = Value(-3.0)
c = a * b
c.backward()
print(a.grad) # Gradient of a
print(b.grad) # Gradient of b