CAB212 · Unit 2: Regression
Gradient descent and learning rate
8 practice questions
Key points
- w := w - alpha * gradient
- Large alpha can diverge; small alpha is slow
- Mini-batch is the practical default
- MSE for linear regression is convex
Gradient descent minimises a loss by repeatedly stepping against the gradient:
w := w - alpha * dL/dw, where alpha is the learning rate.
Worked example: w=2, gradient=4, alpha=0.1 gives w = 2 - 0.1*4 = 1.6.
- alpha too small: very slow convergence.
- alpha too large: overshoots, oscillates or diverges.
| Variant | Data per update | Notes |
|---|---|---|
| Batch | All samples | Stable, slow per step |
| Stochastic (SGD) | One sample | Noisy, fast, can escape shallow minima |
| Mini-batch | Small batch (e.g. 32) | Standard in practice |
The MSE loss for linear regression is convex: one global minimum, so gradient descent converges to it with a suitable alpha. Feature scaling speeds convergence.
Exam pitfall: the gradient points uphill; we subtract it.
Try two questions
Why does feature scaling help gradient descent?
- It removes the need for any learning rate
- It turns the loss function non-convex
- It makes the loss surface more spherical so steps converge faster
- It makes the gradient grow to infinity
Show the answer
C. Similar feature ranges avoid elongated valleys.
Mini-batch gradient descent is preferred in practice because it:
- Balances noisy updates, speed and hardware efficiency
- Uses zero memory during training
- Always converges in a single step
- Needs no learning rate at all
Show the answer
A. It trades off between batch stability and SGD speed.