Loss Calculator
Gradient descent on one weight, step by step
A React app built to learn the calculus behind training AI models. It models a single weight: the prediction is the weight times the input, the loss is the squared error, and the gradient is the derivative of that loss with respect to the weight. The input, target, weight and learning rate are all editable, and every equation is shown three ways: its symbolic form, the current values substituted in, and the result. Each step of gradient descent is recorded, and charts plot the loss by step along with its first and second finite differences, discrete estimates of L′(t) and L″(t). The learning rate is kept in a stable range: rates above 1/x² make the loss grow, so the calculator refuses them, and the slider stays below 1/(2x²) so the weight never jumps past the minimum-loss point, lowering itself automatically when the input grows.
Started Last updated
November 2026