Why plain gradient descent zigzags and momentum does not

L2WorkingConcept8 minML depthScreen

RolesLLM Product EngineeringAI Data SystemsInference Engineering

The question

You minimize the Rosenbrock function from the point (-1, 1). Plain gradient descent creeps along the curved valley and needs thousands of steps. The same run with momentum arrives much sooner. Explain what the valley does to plain descent and what momentum changes.

Answer it first, aloud or on paper. Then open the answer.

The answer

Show short answer

In a narrow valley the gradient points across the valley, not along it, so each plain step jumps from one wall to the other and makes little progress toward the minimum. Momentum keeps a velocity that sums past gradients. The across components flip sign and cancel, the along component keeps its sign and builds up, so the path is smooth and fast.

Show full answer

The function

The function is (1 - x)^2 + 100 (y - x^2)^2. Its minimum is at (1, 1), at the bottom of a curved valley. The factor 100 makes the valley walls steep and the floor almost flat, so the gradient is large across the valley and small along it.

Plain descent

The update is w = w - lr times gradient. The step size is set by the learning rate alone. A learning rate large enough to move along the floor overshoots across the walls, and a learning rate small enough to stay inside the walls crawls along the floor. The lesson runs this with a learning rate of 0.0005 for 5000 steps and still sees slow progress.

Momentum

output
v = beta * v + gradient
w = w - lr * v

The velocity is an exponential sum of past gradients. Components that flip sign at each step cancel inside the sum. Components with a stable sign add up and the ball rolls faster along the floor. The lesson uses beta equal to 0.9, which keeps about the last ten gradients in play. A larger beta gives more smoothing and a slower response when the valley turns.

Where this leads

Adam goes one step further and also divides each weight's step by the running size of its gradients, so each weight gets its own step size. On the Rosenbrock run in the lesson, Adam with a learning rate of 0.01 converges fastest, momentum follows a smoother path, and plain descent trails.

Follow-ups

  1. L2WorkingWhat does beta control?

    Show expected answer

    how much of the past velocity survives each step; 0.9 keeps roughly the last ten gradients.

  2. L3SeniorMomentum overshoots the minimum and comes back. Why?

    Show expected answer

    the velocity carries the point past the bottom when the gradient has already changed sign; a smaller beta or a decaying learning rate damps it.

  3. L3SeniorHow does this zigzag show up in a real training run?

    Show expected answer

    the loss drops fast and then plateaus while the weights oscillate; a smaller learning rate or momentum smooths it.

  4. L4StaffWhy does Adam help on the same valley beyond what momentum does?

    Show expected answer

    it scales each weight's step by the inverse of its running gradient size, so the steep direction takes small steps and the flat direction takes large ones.

Wrong answers

Show the wrong answers that interviewers hear
  • “Raise the learning rate until plain descent moves faster.”

    A larger step jumps further across the valley and diverges before it speeds up the along direction.

  • “Momentum is a bigger learning rate.”

    The velocity grows only where gradients keep their sign and cancels where they flip, which a scalar learning rate cannot do.

  • “The valley is a local minimum, so the optimizer is stuck.”

    The gradient is not zero on the valley floor. The point moves at every step, slowly.

Taught in

The optimization lesson builds plain descent, momentum and Adam and runs them on the Rosenbrock function.