What is gradient descent?
Gradient descent is an iterative method for finding the minimum of a function. At each step it computes the gradient, the direction in which the function rises fastest, and moves the parameters a small step the opposite way. The update rule is θ ← θ − α∇L(θ), where α is the learning rate.
Almost every neural network is trained with some form of gradient descent, from small classifiers to large language models. Backpropagation supplies the gradient of the loss with respect to each weight, and gradient descent uses it to update the weights. Variants such as SGD with momentum and Adam change how the step is computed, but they all follow the same downhill idea.
Key ideas
- Gradient descent repeatedly moves the parameters opposite the gradient of the loss.
- The learning rate sets the step size; too large diverges, too small crawls.
- Steps shrink near a minimum because the gradient shrinks.
- Long, narrow valleys make plain gradient descent zigzag.
- Mini-batches trade a noisier gradient for much cheaper steps.
- On non-convex losses it finds a good low point, not necessarily the global minimum.
Short takes on this topic
Common questions
Does gradient descent always find the global minimum?
Only on convex functions, such as the loss of linear or logistic regression, with a suitable learning rate. Neural network losses are not convex, so gradient descent can stop at a local minimum or slow down near a saddle point. In practice, the minima it finds in large networks tend to work well.
How do you choose a learning rate?
A common approach is a learning rate range test: train briefly while raising the rate exponentially, then pick a value a little below where the loss starts to blow up. Typical starting points are around 0.1 for SGD with momentum and 0.001 for Adam. Most training runs then lower the rate over time with a schedule.
Why is it called stochastic gradient descent?
Each step uses a randomly chosen example or mini-batch instead of the full dataset, so the gradient is a random estimate of the true one. In modern usage, SGD almost always means mini-batch gradient descent. Shuffling the data each epoch keeps the batches representative.
What is the difference between gradient descent and Adam?
Plain gradient descent moves every parameter by the same learning rate times its gradient. Adam keeps running averages of each parameter's gradient and squared gradient, which adds momentum and scales the step separately for every parameter. That helps on loss surfaces with very different curvature in different directions.
Related explainers
- Derivatives — The calculus behind gradient descent
- Loss Functions — How networks measure their mistakes
- Backpropagation — How networks learn from their mistakes
- Optimizers — SGD, momentum, and Adam — smarter gradient descent
- Learning Rate Scheduling — Step decay, cosine annealing, warmup, and the LR range test
- Convexity, Minima & Saddle Points — Why some optimization problems are harder than others
References
- Goodfellow, Bengio & Courville (2016), "Deep Learning", section 4.3: Gradient-Based Optimization
- Stanford CS231n, "Optimization: Stochastic Gradient Descent"
- Ruder (2016), "An overview of gradient descent optimization algorithms"
- Smith (2017), "Cyclical Learning Rates for Training Neural Networks"
Last updated
Gradient Golf