About Gradient Descent on the Rosenbrock Function
This page runs the four optimizers on the Rosenbrock function f(x, y) = (1 - x) squared + 100 (y - x squared) squared with a very small learning rate of 0.002, close to the largest rate that plain gradient descent tolerates here. It is free, needs no sign-up and runs in your browser, so nothing you enter is uploaded.
The minimum is at (1, 1), at the end of a long curved valley whose floor is almost flat while its walls are steep. A larger learning rate sends plain gradient descent bouncing off the walls and out of control: at 0.005 SGD and Momentum diverge, so they are forced to creep along the floor at a tiny rate.
At this small rate SGD and Momentum do reach the bottom within 500 steps, and Momentum gets there first, while RMSprop and Adam, which move about one learning rate per step, are still on the way. Their advantage is the opposite one: raise the rate to 0.01 and they keep going while SGD and Momentum diverge.
How to use Gradient Descent on the Rosenbrock Function
- Choose a function. The suggested learning rate for it is filled in.
- Change the learning rate if you like. Smaller is slower and safer, larger is faster until it blows up.
- Press Step to move every optimizer once, or Play to animate. "+25 steps" skips ahead.
- Tap the plot to move the starting point (the cross). The paths restart from there.
- Read the table for each optimizer's position, value and status: running, converged or diverged.
- Watch the log chart: a line that keeps falling is converging, and a line that climbs is diverging.
Features
- Seven functions: three curves and four 2D surfaces, including a narrow valley, Rosenbrock, Himmelblau and a saddle.
- SGD, Momentum, RMSprop and Adam, all from the same start with the same learning rate.
- Contour map for 2D functions and a curve for 1D, with a coloured path for each optimizer.
- Divergence detection that stops a run and says which optimizers blew up.
- A log-scale chart of the function value against step.
- Step, play and +25 steps controls, with slower playback if you prefer reduced motion.
- Tap the plot to choose the starting point.
Worked examples
Rosenbrock from (-1.5, 2), learning rate 0.002, 500 steps gives SGD 0.0005, Momentum 0, RMSprop 4.4427, Adam 5.7401
The minimum value is 0 at (1, 1). At a learning rate of 0.01 the result is: SGD diverged, Momentum diverged, RMSprop 0.6915, Adam 4.2139.
Privacy: how it works
- Everything is computed in your browser tab. Nothing is sent to Ulkaa or anyone else.
Tips
- On the parabola, try a learning rate of 0.5: SGD jumps to the minimum in a single step because the step size matches the curvature exactly.
- On the double well, drag the start to the left side and see it settle in the other, shallower minimum.
- On Himmelblau, change the start point and see different optimizers choose different minima.
- If a path vanishes off the plot, check the status column: it probably diverged.
Frequently asked questions
Is it really free?
Yes. There is no price, no trial and no credit card. Ulkaa Tool does the work with your own device, so there is no server bill to pass on to you.
Do I need an account?
No. There is no sign-up and no login. Open the page and use it. An Ulkaa account is not needed for anything on this tool.
Does it run in my browser?
Yes. Your settings are processed by code running in your browser tab, on your own device.
Is my data uploaded?
No. Your settings are never sent to Ulkaa or to anyone else. You can check this yourself by watching the Network tab in your browser developer tools while you use the tool.
Why is the Rosenbrock function hard to optimise?
Its minimum lies in a narrow, curved, nearly flat valley with steep sides, so gradients point across the valley instead of along it.
Where is the minimum of the Rosenbrock function?
At (1, 1), where the value is 0.
More Gradient Descent Visualizer pages
- Gradient Descent VisualizerCompare SGD, Momentum, RMSprop and Adam side by side, step by step, on curves and contour maps.
- Learning Rate Too High: Gradient Descent DivergenceSee the error grow instead of shrink when the learning rate crosses its limit.
- SGD Learning Rate VisualizerChange the learning rate and watch plain gradient descent speed up, oscillate or stall.
- Momentum vs SGDSee how a running velocity helps gradient descent in a long, narrow valley.
- Adam Optimizer VisualizerSee Adam adapt its step per direction on the curved Rosenbrock valley.
- RMSprop Optimizer VisualizerSee RMSprop normalise its steps on a surface with four minima.
- Gradient Descent and Local MinimaStart on one side of a double well and see which minimum each optimizer reaches.
- Gradient Descent at a Saddle PointStart almost on a ridge and see how long each optimizer takes to escape the saddle.
- Gradient Descent on a Bumpy LossSee how a bumpy loss traps plain gradient descent and how momentum helps.