Image Gallery

Click on an image to read more about it.

Project Overview

This implementation mirrors Andrej Karpathy's micrograd: a scalar Value type tracks data, grad, the producing op, and parents. Ops build a DAG and backward() topologically sorts nodes and executes stored local backward closures to accumulate gradients.

Supported Operations

Addition, subtraction, multiplication, division (via power -1), power by scalar, tanh, and exp. Each op defines its local gradient rule and contributes to reverse-mode accumulation.

MLP

A simple MLP is built from Neuron, Layer, and MultiLayerPerceptron classes. Activation uses tanh. Parameters are lists of Value objects, so gradients propagate through the whole network.

Training and Loss

Mean squared error over scalar outputs. Mini-batch selection is optional. After computing loss, call backward(), then update each parameter with SGD like p.data -= lr * p.grad and zero grads.

×