Short answer: Gradient descent minimizes a differentiable function by repeating x ← x − η∇f(x). The gradient is the direction of steepest increase, so the minus sign descends. A step size η that is too large diverges. A step size that is too small crawls. On a convex function with a Lipschitz gradient, a sufficiently small constant step converges to the global minimum. On a nonconvex function the same loop converges, when it converges, to a stationary point that may be a saddle or a poor local minimum.
What the problem actually asks
The first-order model of f at x is f(x) plus the gradient dotted with the step. Choosing the step opposite the gradient decreases that model. The real function decreases too when the step is small enough that the linear model still dominates the remainder. That is the entire local argument.
Machine-learning training adds stochastic gradients, estimated on a minibatch, and a schedule for η. The algorithm here is the full-gradient iteration. Stochastic gradient descent is the noisy relative. Newton’s method uses curvature and is a different update.
What the algorithm guarantees
If ∇f is Lipschitz with constant L and η is in (0, 2/L), the function values decrease and, for convex f, the iterates approach the set of minimizers at a rate that depends on strong convexity when it holds. Without strong convexity the typical smooth convex rate on the gap is O(1/t). None of those rates apply to an arbitrary nonconvex loss. Extra memory is the gradient vector. Each iteration costs one gradient evaluation.
A line search or a decreasing schedule can replace a hand-picked η. Momentum and adaptive methods change the direction or the per-coordinate step. They are not plain gradient descent, and a proof for plain gradient descent does not transfer unchanged.
The working steps
- Choose a start x and a step η. If a Lipschitz estimate L is known, take η below 2/L. Otherwise start small and watch the function value.
- Compute the full gradient at x. Subtract η times the gradient from x.
- If the function value rose, the step was too long for the local model. Reduce η and do not treat the risen value as progress.
- Stop when the gradient norm is near zero, or when a budget ends. A near-zero gradient is a stationary point. On a nonconvex function, compare function values from several starts.
- For a convex problem with the step conditions above, the stationary point is a global minimizer. State that hypothesis when you claim it.
The minus sign is the descent. Adding the gradient ascends. The global-minimum claim needs convexity. Stochastic minibatches need a different, noisier analysis. A Lipschitz step-size rule needs L. Guessing η = 0.01 is a heuristic, not that rule.
Approaches that look simpler and fail
| Approach | Why it fails when the gradient is added instead of subtracted |
|---|---|
| Step in the direction of the gradient to minimize | The gradient points uphill. The descent step subtracts it. |
| Keep a constant step that increased the loss | The linear model has failed. Continuing amplifies the overshoot. Reduce the step or use a line search. |
| Call the limit a global minimum on a nonconvex loss | It is a stationary point of the iteration that was run. Another basin can be lower. |
| Quote the convex O(1/t) rate for a stochastic minibatch | That rate is for the full gradient under convexity and a suitable step. Minibatch noise has its own bounds. |
A local root of a derivative, with a quadratic phase near the root, is Newton’s method. A symmetric positive-definite linear system can use conjugate gradients instead of a generic descent. Gradient descent is the first-order subtraction of the gradient.
A working example
This Python fragment steps against the gradient of (x−3)². The derivative is 2(x−3). From 0, with step size 0.4, ten steps land on 3.
x = 0.0
for _ in range(10):
grad = 2 * (x - 3)
x = x - 0.4 * grad
assert abs(x - 3) < 1e-6
print(f"{x:.0f}")
Where it is used
Gradient descent trains neural networks and logistic regression: PyTorch SGD and its relatives step the parameters against the gradient. A line search or Adam changes the step length, not the direction’s meaning. Newton’s method uses the Hessian and is a different update.
When you can drop this algorithm
Drop a fixed step that increases the function. Use a smaller step or a line search. Keep plain gradient descent when the gradient is available and the convexity hypotheses, if you use them, are actually true.
Why this stays published
We publish this so a search for gradient descent returns the minus-gradient update and the convexity hypothesis behind a global minimum. Gradient descent minimizes by subtracting a step times the gradient, and it reaches a global minimum when the function is convex and the step is small enough for the gradient’s Lipschitz constant.
本文由 HoHo 與 AI 協作整理,最後更新於 2026 年 11 月 13 日。
