liveBook · Manning

Gradient

As explained in Ensemble Methods for Machine Learning

A gradient is the vector of partial derivatives of a scalar function with respect to its input variables.

A gradient collects the first derivatives of a function with respect to its variables. Intuitively, it measures the local slope of a surface and points toward steepest ascent. To minimize a function, move in the opposite direction. section 5.1.1

This turns optimization into a guided search. Rather than evaluating every point on a potentially expensive grid, use derivative information to choose a promising direction, then decide how far to move. For a loss function, descending the gradient seeks a model with lower error. section 5.1 section 5.1.1

A gradient-descent iteration proceeds as follows:

  • Compute the negative gradient at the current position. section 5.1.1

Following the Branin surface

The two-variable Branin function provides a visual example. Starting at [-4, -5], gradient descent follows a descending path toward one of several local minima. Near the solution, steps become smaller and the path may zigzag; different starting points can reach different minima. section 5.1.1

Figure 5.2 The surface plot (left) and contour plot (right) of the Branin function. We can visually verify that this function has four minima, which are the centers of the elliptical regions in the contour plot.
CH05_F02_Kunapuli

Use the surface and contour plots to relate gradient direction to the geometry of local minima. section 5.1.1

How Ensemble Methods for Machine Learning covers it

How deep it goes
Explains first-order slope, descent direction, step selection, convergence, and a working implementation, while deferring second-order curvature.
Examples
Uses the Branin function, surface and contour plots, descent paths, and a NumPy/SciPy implementation.
What it assumes
Assumes functions, variables, and first derivatives, while grounding their optimization role through visual and procedural examples.
What you can do after
Builds a simple gradient-descent optimizer and interprets its path toward local minima.
How it connects
Links loss functions, gradient descent, gradient boosting, Newton’s method, and the Hessian matrix.

Also explained in

Compare how 20 books explain gradient →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Ensemble Methods for Machine Learning. The section links point to the parts of the book it draws on.