This repository contains a from-scratch reimplementation of a minimal automatic differentiation engine and a fully connected neural network, inspired by Andrej Karpathy’s micrograd.
The goal of this project was not performance, but deep conceptual understanding of backpropagation, reverse-mode autodifferentiation, and neural network training.
- Custom
Valueclass supporting automatic differentiation - Operator overloading for arithmetic operations
- Dynamic computation graph construction
- Reverse-mode backpropagation via
.backward() - Correct gradient accumulation for reused nodes
- Computation graph visualization using Graphviz
- Forward and backward flow inspection
Neuron,Layer, andMLPabstractions- Fully connected architecture
- Tanh activation
- Manual parameter collection
- Mean squared error loss
- Manual gradient descent
- Parameter updates without external ML libraries
Modern deep learning frameworks (PyTorch, TensorFlow) hide most of these details. This project reconstructs the core mechanics explicitly:
- How gradients flow through a computation graph
- Why backpropagation works
- How neural networks are trained via gradient descent on a composed function
- Python
- NumPy
- Graphviz (for visualization)
- Andrej Karpathy — Neural Networks: Zero to Hero