Skip to main content

Lesson 9 · 14 min

Build a tiny neural net from scratch

Forward pass, loss, gradient, weight update. A real (tiny) classifier in 60 lines of plain JavaScript.

What we're building

A logistic regression classifier — the simplest possible neural net. One layer. One sigmoid. Trained with gradient descent on toy 2D points.

The code below has every piece a real PyTorch model has, just smaller and without abstractions.