talira

micrograd

Tiny scalar autograd engine and neural network library with a PyTorch-like API

open sourceMITfree

micrograd is Andrej Karpathy's tiny autograd engine: it implements backpropagation (reverse-mode autodiff) over a dynamically built graph of scalar values, with a small neural network library on top that has a PyTorch-like API, in about 100 and 50 lines of code. It's enough to train small neural nets, such as a binary classifier in its demo notebook, and its maker describes it as potentially useful for education.

Problems it solves

  • understand how backpropagation works by reading a tiny implementation
  • minimal autograd engine to learn from
  • build a small neural net from scratch in Python

Features

  • reverse-mode autodiff over scalar values
  • small neural network library
  • PyTorch-like API
  • about 150 lines of code

Limitations

  • Its maker describes it as potentially useful for educational purposes.1
  • Operates only on scalar values, not tensors.1

Alternatives

The same job

These do what micrograd does.

  1. tinygrad Small, hackable deep learning framework and compiler, between PyTorch and micrograd

Compare micrograd with the top 3