Introduction: Descending a Mountain in the Fog
Imagine: you're at the top of a mountain in thick fog. You can't see the village down below. But you feel a slope under your feet. You take a step in the direction where it goes down the steepest. Then another. Little by little, you descend.
This is exactly what gradient descent does. It measures the "slope" (gradient) and moves in the opposite direction to reduce the error.

The Fundamental Equation
Symbol by symbol:
- ("theta"): all the model's learned parameters at once, its millions of dials gathered under one name. This is what gets changed.
- : the loss obtained with those particular settings. This is what we want to bring down.
- ("nabla"): the gradient. For every dial, which way and how far to turn it in order to make the loss go up.
- ("eta"): the learning rate, the step size. A plain number, often 0.001.
The minus sign is the whole mechanism: the gradient says where uphill is, and we go the other way. If the error rises sharply when a dial turns right, turn it left.
The Learning Rate: Your Biggest Lever
It is the setting that matters most. It is called a hyperparameter: something you choose before training, as opposed to the parameters that training itself discovers.

Too High
Learning rate = 0.1. You take huge leaps. You jump over the minimum. Your weights oscillate. Or worse, they diverge (explode toward infinity). The error goes up instead of down.
Too Low
Learning rate = 0.00001. You advance at a snail's pace. Training takes days. And you risk getting stuck in a small local minimum.
The middle ground
You need the right dose: large enough to make progress, small enough not to overshoot. In practice you do not look for a single value, you start high and reduce as training goes on. That is called a learning rate schedule.
While we are here: an epoch is one complete pass over the whole training set.
| Epoch | Learning rate | Strategy |
|---|---|---|
| 1-10 | 0.01 | Big steps to explore |
| 10-50 | 0.001 | Medium steps |
| 50+ | 0.0001 | Tiny steps to fine-tune |

Three Ways to Compute the Slope

Full-batch gradient descent
You compute the gradient on all your data before making a single weight update.
Advantage: very precise.
Disadvantage: ultra slow. With 1 million examples, you wait a long time before the first update.
In practice: almost never used.
Stochastic Gradient Descent (SGD)
You compute the gradient on a single example at a time. "Stochastic" simply means "drawn at random". Update after each example.
Advantage: very fast.
Disadvantage: noisy, unstable. Gradients from one example can be weird.
In practice: reserved for cases where data arrives as a continuous stream, one item at a time.
Mini-batch SGD (the standard)
You compute the gradient on 32, 64, or 128 examples at a time.
Advantage: the right compromise. Enough data at once to keep a Graphics Processing Unit (GPU) busy, since it computes in parallel; few enough to make many updates.
Disadvantage: none really.
In practice: this is what's always used. When someone says "SGD," they actually mean mini-batch.
32-256 is standard. On GPU, you can go 512 or more. On a small computer, 32 is enough. Larger = more stable but fewer updates per epoch.
Momentum: Avoiding Oscillations
Problem with plain SGD: if the error surface is a "ravine" (very steep in one direction, almost flat in another), the gradient oscillates in a zigzag instead of going straight.
It's like a ball in a narrow bowl. It bounces from one side to the other, slowing down at each turn. Frustrating.
Solution: accumulate velocity. Remember past gradients.
Symbol by symbol: numbers the training steps; (for velocity) is the momentum accumulated at step ; is the previous step's; ("beta") is a number between 0 and 1 saying what fraction of the old momentum is kept; is the current gradient, and the learning rate as above.
In one sentence: instead of following the slope of the moment, follow an average of the recent slopes, and let that average move the parameters.
This is how a rolling ball behaves: it picks up speed on steady descents. The left-right oscillations, meanwhile, cancel from one step to the next and average out, which is precisely the effect being sought.
is the typical value: 90% of the previous momentum is kept, so the memory spans about ten steps. At the inertia is stronger, at weaker.
Nesterov Accelerated Gradient (NAG)
Clever trick: instead of computing the gradient where you are now, compute it where you would be after the momentum step.
It's like taking a step forward, looking at the slope there, then adjusting your direction. This helps avoid overshooting minima.
Faster than classic momentum. Used in modern optimizers.

The Error Landscape in High Dimensions
In 2D, you imagine a mountain. Local minima, plateaus. Simple.
In millions of dimensions (millions of weights), it gets weird:
Saddle Points vs Local Minima
In very high dimensions, true "trap" local minima are rare. Most stationary points are saddle points: one direction goes down, another goes up. Why a non-convex landscape still lets itself be descended is the subject of convexity; the notion of a gradient is rebuilt from scratch in derivatives and gradients, and the algorithm's variants in gradient methods.
When descending, you naturally pass through the saddle point (continue in the descending direction).

Low-Error Valleys
Good minima (with low error) are often connected by "valleys" of similar error. There isn't one minimum, there are thousands that are all good.
This means: you don't need to find the best weights. You can stop anywhere in the right valley.
Skip Connections for a Smoother Landscape
Residual networks (ResNets) use residual connections, also called skip connections: a direct path lets the data, and therefore the gradient, bypass certain layers. Result: the error landscape is much smoother.

This is why we can train very deep networks (100+ layers) now. Before, they would diverge. Skip connections make gradient descent more robust.
Instability in Depth
Problem: during backpropagation the gradient must cross every layer, being multiplied at each one. In a deep network it ends up either swelling out of control (exploding gradients) or dying out (vanishing gradients). See Backpropagation for the mechanism.
Solutions:
Gradient clipping: when the gradient exceeds a set length it is shortened to that length, without changing its direction.

Smart initialization: the Xavier and He methods pick the weights' starting values from the number of inputs each layer has, so the gradient crosses the layers without either swelling or dying out.

Normalization: BatchNorm, LayerNorm. Keeps activations within a healthy range.

Practical Summary
Start with SGD plus momentum () and batches of 64 to 256 examples.
For the learning rate, the classic empirical method: run a very short training while ramping the rate from 0.0001 up to 0.1, and watch which range makes the loss fall fastest.
If you want something more modern, use Adam or AdamW, covered in Modern optimizers.
Add a schedule: start high, reduce progressively.
Simple as that, and it works for the majority of cases.
1. In the update θ = θ − η · ∇L, what exactly does the gradient provide, and what decides the step size?
2. What happens with a learning rate that is far too high?
3. When a practitioner says they train « with SGD », what are they almost always doing in reality?
4. How does momentum kill the zigzags in a ravine of the error landscape?
5. In millions of dimensions, must you find THE global minimum of the error landscape?