Learning and architectures / 5 of 7
Gradient descent in practice
What you’ll learn
- Explain the main idea of “Gradient descent in practice” in your own words.
- Trace a concrete example and identify the assumptions behind it.
- Apply the principle in a practice problem and recognize a common failure.
The idea, intuitively
Training often uses minibatches to estimate gradients from a subset of examples. This is cheaper than processing the entire dataset for every update, but introduces noise into the optimization trajectory.
Treat a neural network as a computation graph, not a mysterious black box. Follow a tiny input through each operation and keep track of tensor shapes. Distinguish the forward pass, gradient computation, and optimizer update. These three stages are connected but solve different parts of the learning problem.
Under the hood
Stochastic gradient descent subtracts a scaled gradient. Momentum accumulates directional history. Adaptive methods rescale updates per parameter. Learning-rate schedules and gradient clipping can improve stability.
An epoch is a pass through the training data; it is not the same as one optimizer step.
A worked example
For a quadratic bowl, a small rate approaches the minimum smoothly. A high rate crosses the valley repeatedly and can move farther away.
How to use this way of thinking
Build intuition with a small calculation before scaling dimensions. Check whether the architecture can represent the desired relationship, then whether optimization can learn it, then whether the learned solution generalizes. A failure in any one of these stages needs a different response.
See the mechanism
Start at −3. Take a step at 0.5, then take several steps at 1.1. Compare the loss in the two runs and use the step history to explain the difference.
Opening the experiment…
Try it yourself
With 1,000 examples and batch size 100, how many full-batch updates occur in one epoch?
Key takeaways
- The gradient of the data objective
- An epoch is a pass through the training data; it is not the same as one optimizer step.
- Check the assumptions with a small example before applying this idea to a larger system.
Check your understanding
Use feedback to learn. Quiz scores and lesson completion are tracked separately.
Go to lesson completionFurther reading
Original papers and reference material for this school. External resources may be in English and require internet access.
Dive into Deep Learning (opens a new tab)PyTorch: automatic differentiation (opens a new tab)Finish this lesson
Mark this lesson complete when you’re ready to continue.