run gradient-descent-3d.bas
MDN-117:22
DEMO by Michele di Nuzzo

Gradient descent in 3D

MDN · LAB GRADIENT DESCENT IN 3D Optimisation · 1847
Drag
rotate the surface
Top map
choose the starting point
Run / Step
continuous race or one step
η
learning rate (log scale)
Space
run / pause

▶ Run ⬇ Download (.html)

Almost every machine-learning model is trained by walking down an error surface: at each step you compute the gradient (the direction of steepest ascent) and move the opposite way. Cauchy described the method in 1847; today it trains networks with billions of parameters.

Here three optimisers start from the same point: plain gradient descent, Momentum (which builds up speed like a rolling ball) and Adam (which adapts the step to each direction).

Things to try

  • Bowl: the valley is long and narrow. GD zigzags between the walls, Momentum picks up speed along the bottom.
  • Rosenbrock: finding the canyon is easy, travelling it to the minimum (1, 1) much less so.
  • Two valleys: change the starting point on the map and see who ends up in the local minimum θ′ instead of the global one θ*.
  • Raise the learning rate: at some point someone diverges.

If you want to play with it, there is Gradient Descent in the Games section.

The demo is a single HTML file: download it and use it offline, even without an internet connection. Licence: CC BY-NC 4.0 — you may share it, crediting the author and this page, but not for commercial purposes.