#2121st of 33 in Learning and cookbooks

micrograd

Scalar-valued autograd engine and tiny neural net library in about 150 lines of Python

Stars
17.8k
License
MIT
Last commit
Aug 2026
Language
Jupyter Notebook

Missed the latest GitHub check; these facts may be older.

Overview

micrograd implements reverse-mode autodiff over a dynamically built DAG of scalar values, with a small PyTorch-like neural network module on top. The engine is about 100 lines and the nn library about 50. A demo notebook trains a 2-layer MLP with two 16-node hidden layers as a binary classifier on the moon dataset, using an SVM max-margin loss and SGD.

Who it is for: Students and engineers learning how backpropagation and autograd work

Strengths

  • Engine and nn library are about 100 and 50 lines, readable in one sitting
  • PyTorch-like API: Value, Neuron and MLP classes with backward()
  • Notebook demos training on the moon dataset and graphviz graph tracing
  • Unit tests check gradients against PyTorch as a reference

Weaknesses

  • Operates on scalars only, so no tensors and very slow for real models
  • No GPU support
  • Demo covers only binary classification with an SVM loss and SGD
  • Tests need PyTorch installed; no tagged releases

What it needs

  • no GPU
  • Needs PyTorch (tests only), graphviz (tracing notebook)

Also in Learning and cookbooks

See all 33
Also in Learning and cookbooks
RankProjectScore
1ai-engineering-from-scratchHands-on AI engineering curriculum with 542 lessons across 20 phases69.1k starsMIT87 out of 100
2generative-ai-for-beginners21-lesson course on building generative AI apps in Python and TypeScript121.4k starsMIT81 out of 100
3hello-agentsChinese-language course on building LLM agents from scratch83.1k starscustom license78 out of 100
#4ai-agents-for-beginners18-lesson course on building AI agents with Microsoft Agent Framework77.2k starsMIT77 out of 100
#5ai-agent-bookOpen book on AI agent design, with 109 runnable companion experiments54.2k starsApache-2.077 out of 100