Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

 Open In Colab

If information about the gradient is available, it can accelerate convergence substantially by pointing in the direction of steepest change.

First order gradient information: Gradient descent methods

If you have information about the gradient, moving down the negative gradient is an intuitive approach to reach the minimum. While straightforward, steepest descent can suffer from severe zig-zagging in narrow valleys, which motivates constructing conjugate directions.

Each step is incremented as:

xi+1=xi+−a∇f(xi)\mathbf{x}^{i+1} = \mathbf{x}^i + - a \nabla f(\mathbf{x}^i)

Steepest descent maximizes the decrease in ff locally, but a modified direction may allow longer steps. It is fast to execute and very parallelizable on GPUs.

Stochastic gradient descent

In machine learning training, optimization involves finding model parameters in very high-dimensional spaces where computing the true gradient over millions of data points is prohibitively expensive.

In Stochastic Gradient Descent (SGD), the gradient is approximated at each step by randomly sampling a mini-batch of data. The step length aa is termed the learning rate, and momentum terms are added to dampen oscillations across ravine-like loss surfaces.

Second order gradient information: Newton’s optimization method

Newton’s optimization routine aims to find the root of the gradient, ∇f(x)=0\nabla f(\mathbf{x}) = \mathbf{0}, which identifies the stationary points (minima, maxima, or saddle points). Since we are focused on a scalar objective f(x)f(\mathbf{x}), the gradient is a vector ∇f\nabla f, and we require the second-order derivative matrix—the Hessian H\mathbf{H}:

H=∂2f∂x2\mathbf{H} = \frac{\partial^2 f}{\partial \mathbf{x}^2}

The increment Δx\Delta \mathbf{x} is solved at each iteration from the linear system:

HΔx=−∇f(x)\mathbf{H} \Delta \mathbf{x} = -\nabla f(\mathbf{x})

where H\mathbf{H} must be symmetric. Newton’s optimization method has quadratic convergence near a minimum, but requires assembling and solving a linear system with the Hessian matrix at every step.

Example: Minimize x4+2y4x^4 + 2y^4

Let’s minimize f(x,y)=x4+2y4f(x, y) = x^4 + 2y^4 starting from an initial guess of x0=(1.5,2.0)\mathbf{x}_0 = (1.5, 2.0):

Example: Minimize x2+y2x^2 + y^2

Now let’s apply Newton’s method to f(x,y)=x2+y2f(x, y) = x^2 + y^2 starting from x0=(1.5,1.5)\mathbf{x}_0 = (1.5, 1.5):

Why does this converge in a single step? Because f(x,y)f(x, y) is an exact quadratic; the second-order Taylor expansion upon which Newton’s method is built is exact everywhere!

Example: Saddle point in x2−6xy+y2x^2 - 6xy + y^2

Let’s test Newton’s method on f(x,y)=x2−6xy+y2f(x, y) = x^2 - 6xy + y^2 with x0=(1.5,2.0)\mathbf{x}_0 = (1.5, 2.0):

Notice what happens: Newton’s step jumps to (0,0)(0, 0) because ∇f(0,0)=0\nabla f(0, 0) = \mathbf{0}. But is (0,0)(0, 0) a minimum? Along y=0y = 0, f(x,0)=x2f(x, 0) = x^2 (curves up), but along y=xy = x, f(x,x)=−4x2f(x, x) = -4x^2 (curves down!). Point (0,0)(0, 0) is a saddle point, and the Hessian is indefinite.