About this project

micrograd provides a minimal scalar-valued autograd engine and a lightweight neural network library built on top of it. The core `Value` abstraction records operations in a dynamically constructed directed acyclic graph and supports backpropagation through supported arithmetic and activation operations, including addition, multiplication, exponentiation, division, subtraction, and ReLU. The README describes the engine and neural network components as roughly 100 and 50 lines respectively, emphasizing clarity and educational use over production-scale tensor performance. The package can be installed with `pip install micrograd`. The example shows constructing expressions from `Value` objects, reading forward-pass results from `.data`, calling `backward()`, and inspecting input gradients through `.grad`. The included `micrograd.nn` module provides neuron, layer, and MLP-style building blocks with a PyTorch-like interface. `demo.ipynb` demonstrates training a two-layer multilayer perceptron as a binary classifier on the moon dataset using a max-margin loss and SGD. Another notebook, `trace_graph.ipynb`, uses Graphviz to visualize computation nodes with both their values and gradients. The test suite uses PyTorch as a reference implementation to verify computed gradients and is run with pytest. The README also links to an external microgpt example showing how a related autograd approach can be used to train and sample from a GPT-2-like transformer. The project is released under the MIT license.