LearnViz CompSci
Home / Learn / AI & Machine Learning / Gradient Descent

Intermediate Topic 18 of 51 AI & Machine Learning

Gradient Descent

Iteratively stepping against the gradient to minimize loss.

How it works

Gradient descent minimizes a loss function by repeatedly moving the parameters a small step in the direction opposite to the gradient, the direction of steepest increase, so theta becomes theta minus learning rate times the gradient. Batch gradient descent uses the whole dataset per step, stochastic gradient descent uses one example and mini-batches strike a balance. Variants such as momentum, RMSprop and Adam adapt step sizes and smooth updates.

Step-by-step walkthrough

  1. Start with random parameters.
  2. Compute the gradient of the loss, the uphill direction.
  3. Take a small step the opposite way, size set by the learning rate.
  4. Repeat many times.
  5. The loss settles at a minimum.

Where it is used

Training linear and logistic regression, neural networks and almost all modern machine-learning models rely on gradient descent and its variants, with gradients computed by backpropagation.

Common pitfall

A learning rate that is too large diverges, while one too small is painfully slow. Non-convex losses have local minima, saddle points and plateaus. Unscaled features cause zigzagging. Vanishing or exploding gradients affect deep networks. Normalize inputs, use learning-rate schedules and adaptive optimizers, monitor the loss curve and clip gradients when needed.

Where it fits in the course

Gradient Descent is topic 18 of 51 in AI & Machine Learning, rated Intermediate. It follows Cross-Validation. The next topic is Loss Functions.

Practice and explore

How to study this topic

  1. Read the explanation above and restate the definition in your own words.
  2. Open the interactive lesson and answer its mini quiz.
  3. Read the common pitfall, then write a short example that avoids it.
  4. Check your understanding in the AI & Machine Learning quiz, and revisit the topic if you miss a question.

Frequently asked questions

What is Gradient Descent?
Iteratively stepping against the gradient to minimize loss. It belongs to AI & Machine Learning and is an intermediate-level topic.
Where do people use Gradient Descent?
Training linear and logistic regression, neural networks and almost all modern machine-learning models rely on gradient descent and its variants, with gradients computed by backpropagation.
What is the most common mistake with Gradient Descent?
A learning rate that is too large diverges, while one too small is painfully slow.
What should I learn before this topic?
Start with Cross-Validation, the topic just before it in AI & Machine Learning.
How can I practice it?
Answer the mini quiz in the interactive lesson, then take the AI & Machine Learning quiz.
Is Gradient Descent hard to learn?
It is an Intermediate topic. Be comfortable with the Beginner topics in this area first, then read the common pitfall carefully, since it is where most mistakes happen.
How long does it take to learn Gradient Descent?
Most learners can read the explanation and finish the interactive lesson in under an hour. Fluency comes from applying the idea, so plan a few short practice sessions with the quiz.
Which topics are related to Gradient Descent?
Cross-Validation, Loss Functions, Confusion Matrix are closely connected. The full list is in the related topics section of this page.
What should I study after Gradient Descent?
Continue with Loss Functions, the next topic in AI & Machine Learning.

Related topics