#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| Rank | Project | Score |
|---|---|---|
| 1 | ai-engineering-from-scratchHands-on AI engineering curriculum with 542 lessons across 20 phases | 87 out of 100 |
| 2 | generative-ai-for-beginners21-lesson course on building generative AI apps in Python and TypeScript | 81 out of 100 |
| 3 | hello-agentsChinese-language course on building LLM agents from scratch | 78 out of 100 |
| #4 | ai-agents-for-beginners18-lesson course on building AI agents with Microsoft Agent Framework | 77 out of 100 |
| #5 | ai-agent-bookOpen book on AI agent design, with 109 runnable companion experiments | 77 out of 100 |