Gradient descent is a way to find the lowest point of a hill by taking small steps downhill. In machine learning, it helps find the best model by reducing errors step by step.
Click to reveal answer
beginner
What role does the learning rate play in gradient descent?
The learning rate controls how big each step downhill is. If it's too big, you might jump past the lowest point. If it's too small, it takes a long time to reach the bottom.
Click to reveal answer
intermediate
Explain the difference between batch, stochastic, and mini-batch gradient descent.
Batch gradient descent uses all data to take one step, which is slow but stable. Stochastic uses one data point per step, which is fast but noisy. Mini-batch uses a small group of data points, balancing speed and stability.
Click to reveal answer
intermediate
Why can gradient descent get stuck in local minima?
Sometimes the error surface has many low points. Gradient descent might find a small dip (local minimum) instead of the lowest dip (global minimum), so it stops there and misses the best solution.
Click to reveal answer
advanced
What is the purpose of using momentum in gradient descent?
Momentum helps gradient descent keep moving in the right direction by remembering past steps. It can speed up learning and help jump over small bumps or flat areas.
Click to reveal answer
What does gradient descent aim to minimize?
AThe number of data points
BThe learning rate
CThe model size
DThe error or loss function
✗ Incorrect
Gradient descent tries to reduce the error or loss function to improve the model's predictions.
If the learning rate is too high, what can happen?
AThe model will always find the global minimum
BThe model converges too slowly
CThe model might overshoot the minimum and fail to converge
DThe model ignores the data
✗ Incorrect
A high learning rate can cause the steps to jump over the minimum, preventing convergence.
Which type of gradient descent updates the model after looking at one data point?
AStochastic gradient descent
BMini-batch gradient descent
CBatch gradient descent
DMomentum gradient descent
✗ Incorrect
Stochastic gradient descent updates the model after each single data point.
What problem does momentum help solve in gradient descent?
AAvoiding local minima
BSpeeding up convergence and smoothing updates
CIncreasing the learning rate automatically
DReducing the size of the dataset
✗ Incorrect
Momentum helps speed up learning and smooth out the updates by remembering past gradients.
Which of these is NOT a type of gradient descent?
ARandom gradient descent
BStochastic gradient descent
CBatch gradient descent
DMini-batch gradient descent
✗ Incorrect
Random gradient descent is not a recognized type of gradient descent.
Describe how gradient descent helps a machine learning model learn from data.
Think about walking downhill to find the lowest point.
You got /4 concepts.
Explain the differences and trade-offs between batch, stochastic, and mini-batch gradient descent.
Consider how much data is used for each update.
You got /3 concepts.
Practice
(1/5)
1. What is the main goal of gradient descent in machine learning?
easy
A. To minimize the error or loss function
B. To increase the number of model parameters
C. To randomly change model weights
D. To maximize the training time
Solution
Step 1: Understand gradient descent purpose
Gradient descent is used to find the best model parameters by reducing errors.
Step 2: Connect to error minimization
The algorithm updates parameters to minimize the loss function, which measures error.
Final Answer:
To minimize the error or loss function -> Option A
2. Which of the following is the correct update rule for a parameter \(\theta\) using gradient descent with learning rate \(\alpha\) and gradient \(\nabla J(\theta)\)?
easy
A. \(\theta = \theta - \alpha \nabla J(\theta)\)
B. \(\theta = \theta + \alpha \nabla J(\theta)\)
C. \(\theta = \alpha \nabla J(\theta) - \theta\)
D. \(\theta = \theta \times \alpha \nabla J(\theta)\)
Solution
Step 1: Recall gradient descent formula
Gradient descent updates parameters by moving opposite to the gradient to reduce loss.
Step 2: Identify correct sign and terms
The update is \(\theta = \theta - \alpha \nabla J(\theta)\), subtracting the gradient scaled by learning rate.
Final Answer:
\(\theta = \theta - \alpha \nabla J(\theta)\) -> Option A
Quick Check:
Update = subtract gradient [OK]
Hint: Subtract gradient times learning rate [OK]
Common Mistakes:
Adding instead of subtracting gradient
Multiplying parameters incorrectly
Swapping terms order
3. Consider this Python code snippet for one step of gradient descent on parameter \(\theta\):
B. Bug: learning rate too small; fix by increasing it
C. Bug: sign error; fix by changing '+' to '-' in update
D. Bug: gradient sign wrong; fix by negating gradient
Solution
Step 1: Recall standard gradient descent formula
The correct update is always \(\theta = \theta - \alpha \nabla J(\theta)\).
Step 2: Identify the bug in code
The code uses '+' instead of '-', performing gradient ascent. With gradient = -4.0, code updates to 5.0 - 0.04 = 4.96 (wrong direction); correct is 5.0 + 0.04 = 5.04.
Final Answer:
Bug: sign error; fix by changing '+' to '-' in update -> Option C
Quick Check:
Always subtract lr * gradient [OK]
Hint: Always use '-' for gradient descent [OK]
Common Mistakes:
Thinking '+' works for negative gradients
Confusing ascent (+) with descent (-)
Ignoring standard update rule
5. You run gradient descent with a very large learning rate \(\alpha = 10\) on a simple quadratic loss \(J(\theta) = (\theta - 3)^2\). What is the most likely outcome after a few steps starting from \(\theta=0\)?
hard
A. The parameter \(\theta\) converges smoothly to 3
B. The parameter \(\theta\) oscillates or diverges away from 3
C. The parameter \(\theta\) stays at 0 without change
D. The parameter \(\theta\) becomes negative infinity
Solution
Step 1: Understand effect of large learning rate
A large learning rate causes big jumps in parameter updates, possibly overshooting the minimum.
Step 2: Analyze behavior on quadratic loss
Since \(J(\theta) = (\theta - 3)^2\), gradient is \(2(\theta - 3)\). Large steps can cause \(\theta\) to jump past 3 repeatedly, causing oscillation or divergence.
Final Answer:
The parameter \(\theta\) oscillates or diverges away from 3 -> Option B
Quick Check:
Large learning rate causes oscillation [OK]
Hint: Too big steps cause oscillation, not smooth learning [OK]
Common Mistakes:
Assuming large learning rate helps convergence
Thinking parameter stays fixed
Confusing divergence with negative infinity
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.