liveBook · Manning

Gradient descent

As explained in Grokking AI Algorithms, Second Edition

Gradient descent is an optimization technique that iteratively changes parameters in the direction that reduces an objective function.

Gradient descent is an optimization technique that repeatedly changes model weights to reduce a cost function. It uses the slope at the current point to choose a direction and step size: move opposite the gradient, with the learning rate controlling the step. section 9.8 section 9.26

A neural network training cycle uses gradient descent like this:

  • Evaluate the network and calculate its error or cost. section 9.8
  • Use backpropagation and the Chain Rule to calculate each weight’s gradient. section 9.26
  • Update every weight in the direction that lowers cost, scaling the change by the learning rate. section 9.26
  • Repeat the process across the training data, while watching for overfitting from training too long. section 9.8

Finding the valley

Imagine standing on a dark, hilly cost landscape. A positive slope means moving forward increases error, so move backward; a negative slope means moving forward decreases error, so move forward. A flat slope may indicate that the minimum is near. In a diffusion model, the same pattern updates weights so predicted noise becomes closer to actual noise over many training steps. section 9.8 section 12.23

Figure 9.25 Example of adjusting a weight by using gradient descent
09_25

Visualizes an individual weight adjustment using gradient descent. section 9.8

How Grokking AI Algorithms, Second Edition covers it

How deep it goes
Explains slope intuition, learning-rate updates, backpropagation, and Chain Rule calculations without pursuing deeper optimization theory.
Examples
Uses a hilly-landscape analogy, weight-versus-cost figures, ANN updates, and diffusion-model noise prediction.
What it assumes
Builds derivative intuition from basic examples while assuming familiarity with neural-network weights and training.
What you can do after
Apply it to update neural-network weights and tune diffusion models toward more accurate predictions.
How it connects
Connects derivatives, cost functions, learning rates, backpropagation, Chain Rule, overfitting, and diffusion models.

Also explained in

Compare how 17 books explain gradient descent →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking AI Algorithms, Second Edition. The section links point to the parts of the book it draws on.