📉 Gradient Descent Visualiser
Watch SGD, Adam, Momentum and RMSprop navigate a 3D loss landscape in real time. Compare convergence speed and path shape across optimisers. Adjust learning rate, momentum and noise.
About this simulation
This visualiser drops one or more optimisers onto a 3D loss landscape and animates the iterative path each one carves towards a minimum. At every step the true gradient of a chosen test function is computed analytically, optional noise is injected, and the parameter update rule for SGD, Momentum, RMSprop or Adam moves the marker downhill. Watching the four trails race across surfaces such as the Rosenbrock valley reveals why adaptive methods handle curvature, narrow ravines and saddle points so differently.
🔬 What it shows
A rendered height field of a classic optimisation benchmark (Rosenbrock, a saddle, Beale's function or Himmelblau). Coloured dots descend it using real update equations: plain SGD (x ← x − lr·g), Momentum, RMSprop's per-axis squared-gradient scaling, and Adam with its bias-corrected first and second moments (β₁, β₂ = 0.999). The white ★ marks the global minimum each path is chasing.
🎮 How to use
Pick an optimiser (or "All four" to compare) and a loss function from the dropdowns. The Learning Rate slider (0.001–0.2), Momentum / β₁ slider (0–0.99) and Gradient Noise slider (0–0.5) reshape the dynamics live. Use Reset to restart, Pause to freeze, and drag to rotate or scroll to zoom the camera. The telemetry panel reports step count, loss, gradient norm and per-step displacement.
💡 Did you know?
The Rosenbrock "banana" function has a global minimum at (1, 1) that sits inside a long, curved, nearly flat valley. Following the gradient slides you into the valley almost instantly, but inching along its floor to the true minimum is notoriously slow — which is exactly why it became a standard stress test for optimisation algorithms.
Frequently asked questions
What is gradient descent?
Gradient descent is an iterative method for minimising a function by repeatedly stepping in the direction of steepest decrease, the negative gradient. Each update is parameter ← parameter − learning_rate × gradient. In machine learning it is the engine that adjusts model weights to reduce a loss, and this page makes that process visible on a 2D-input surface drawn in 3D.
How do SGD, Momentum, RMSprop and Adam differ?
SGD takes a fixed-size step along the raw gradient. Momentum accumulates a velocity so it builds speed in consistent directions and damps oscillation. RMSprop divides each step by a running average of squared gradients, giving every axis its own adaptive scale. Adam combines momentum and RMSprop-style scaling with bias correction, which is why it often converges fastest here.
What do the learning rate and noise sliders do?
The learning rate sets how far each step moves; too small and convergence crawls, too large and the marker overshoots or diverges. Gradient Noise adds random perturbation proportional to the gradient magnitude, mimicking the stochastic gradients of mini-batch training and showing how each optimiser copes with imperfect direction estimates.
Is the simulation mathematically accurate?
Yes for the core mechanics. The gradients of all four loss functions are coded analytically, and the four update rules implement the standard equations, including Adam's bias-corrected moments with β₂ fixed at 0.999. It is a faithful 2-parameter teaching model rather than a full deep network, so it omits mini-batches, weight decay and learning-rate schedules.
Why do optimisers sometimes get stuck or behave oddly?
On the saddle surface the gradient nearly vanishes along one direction, so plain SGD can stall while adaptive methods escape faster. On Himmelblau there are four separate minima, so the starting point decides which basin a path falls into. These behaviours illustrate that gradient descent finds a local minimum near where it begins, not necessarily the global one.
Watch SGD, Momentum, RMSprop and Adam navigate a 3D loss landscape in real time. Compare convergence speed and trajectory shape. Adjust learning rate, momentum and gradient noise.
3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install