Back to articles

Algorithmic Fundamentals:
Gradient Descent

Behind ChatGPT, Midjourney, and every modern neural network lies one simple, powerful idea for finding the "bottom of the valley."

Apr 15, 202512 min readAI Fundamentals

Executive Summary

If you strip away the massive datasets, the thousand-GPU clusters, and the complex transformer architectures of modern AI, you are left with a single mathematical problem: Optimization.

How do you tweak billions of parameters until the network stops making mistakes? The answer isn't magic. It's an algorithm used for decades called Gradient Descent. This post explains how it works without drowning you in calculus.

1. The Goal: Making Mistakes Smaller

At its core, training a neural network is just trying to minimize errors.

We measure this error using a Loss Function. Think of the Loss Function as a judge that gives the model a score based on how bad its predictions are.

  • Prediction is perfect? Loss is near 0.
  • Prediction is terrible? Loss is very high.

The goal of training is simple: find the exact combination of network weights that results in the lowest possible Loss.

2. The Analogy: The Hiker in the Fog

Imagine you are standing on a vast, complex mountain range. Thick fog surrounds you; you can only see three feet in front of you.

Your goal is to get to the absolute lowest point in the entire landscape (the "Global Minimum" loss).

You don't have a map. You don't know where the bottom is. So, what do you do?

  1. 1You feel the ground around your feet with your toe.
  2. 2You find the direction that is steepest downhill.
  3. 3You take a small step in that direction.
  4. 4You repeat the process.

This is exactly what Gradient Descent does mathematically.

  • The Mountain: The Loss Landscape (all possible error values).
  • Your Coordinates: The current values of the network's parameters (weights).
  • The Steepness: The Gradient (calculated via calculus/backpropagation).
  • The Step Size: The Learning Rate.

⚠️ If your step size is too big, you might overshoot the valley and jump to the other side. If it's too small, it will take 10,000 years to get to the bottom.

3. Reality Check: Stochastic Gradient Descent (SGD)

In the analogy above, to find the perfect downhill direction, you'd have to check the entire mountain topography at once.

In AI terms, this means running every single piece of data you have through the model just to figure out one single step. For massive datasets, this is impossibly slow.

The solution: approximate.

Instead of evaluating the entire landscape, we sample a small subset of data points (a "mini-batch"), compute the loss for just those few, and estimate the downhill direction based on this limited but representative view.

This is called Stochastic Gradient Descent (SGD). "Stochastic" refers to the probabilistic sampling of training data—we trade perfect information for computational efficiency.

Because we are approximating based on limited data, our path down the mountain isn't a smooth, straight line. It's noisy; it oscillates. But on average, it converges toward the minimum faster because we take many quick, iterative steps instead of one perfect but computationally expensive step.

Here is a visualization of that noisy path in action on a 2D loss landscape:

Loss Landscape
SGD Path

A top-down view of SGD taking noisy steps toward the center minimum.

Conclusion

Gradient Descent is the workhorse of the AI revolution. While researchers constantly invent new architectures and activation functions, the underlying mechanism for learning remains surprisingly simple: feel the slope, take a step down, and repeat billions of times.

Research & Sources