The derivative: measuring change
Imagine you're driving a car. The speedometer reads 55 mph. What exactly is it measuring? The rate of change of your position with respect to time. If you accelerate, this rate increases. If you brake, it decreases. The derivative is exactly that: it measures how fast one quantity changes when you slightly modify another.
Mathematically, the derivative of at point is defined as:
You take two very close points on the curve of , compute the slope of the line connecting them, and let the distance between those two points approach zero. What you get is the slope of the tangent line to the curve at point .

The mountain analogy
Imagine you're on a mountainside, blindfolded. You can't see anything, but you can feel the slope under your feet. The derivative is that slope. It tells you two essential things:
- Direction: is it going up or down?
- Intensity: is the slope steep or gentle?
If the derivative is positive, the function is increasing. If it's negative, the function is decreasing. If it's zero, you're on a plateau, a peak, or a valley, a critical point.
Fundamental examples
Here are the derivatives you'll constantly encounter in ML:
The power function:
The simplest case: gives . At , the slope is , the function is climbing faster and faster. At , the slope is , that's the minimum. This function appears everywhere in ML because the MSE loss (Mean Squared Error) is exactly an : you measure the square of the error between prediction and reality.
The exponential:
The exponential is its own derivative. It's a magical property that makes it ubiquitous in mathematics. In ML, it appears in the softmax function (which transforms scores into probabilities) and in many probability distributions.
The logarithm:
The logarithm grows more and more slowly. Its derivative decreases with . In ML, we very often work with the log-likelihood: we take the logarithm of probabilities to transform products into sums. The cross-entropy loss, used in nearly all classification, relies on .
The sigmoid:
The sigmoid squashes any real number into the interval . Its derivative is maximal at (where it equals ) and tends toward when is very large or very small. This phenomenon is called saturation: in those zones, the gradient becomes tiny, and learning slows down considerably. It's one of the historical problems of deep learning, known as the vanishing gradient.

From scalar to vector: the gradient
In the real life of a neural network, you never depend on a single variable. A model has thousands, even billions of parameters. You need a multidimensional version of the derivative: the gradient.
If depends on several variables , the gradient is the vector of all partial derivatives:
Each component says: "if I slightly move this parameter, how much does the function change?"
The key property of the gradient
The gradient points in the direction of steepest ascent of the function. This is a fundamental result of multivariate analysis. If you want to climb the mountain as fast as possible, follow the gradient. If you want to descend as fast as possible (and that's exactly what we want in ML, since we want to minimize the loss) go in the opposite direction of the gradient.
Gradient descent: the training algorithm
Training an ML model boils down to an optimization problem: finding the parameters that minimize a loss function . Gradient descent is the simplest algorithm to get there:
At each step:
- Compute the gradient: in which direction does the loss increase the most?
- Take a step in the opposite direction: update the parameters to reduce the loss
- Repeat until convergence
The parameter is called the learning rate. It's the size of the step you take at each iteration.
The learning rate: not too big, not too small
- Too small: convergence is extremely slow. You're taking ant steps on the mountain.
- Too big: you oscillate around the minimum without ever reaching it, or worse, you diverge. You're taking giant leaps and jumping over the valley.
- Just right: you descend quickly and converge cleanly to the minimum.
In practice, choosing the learning rate is one of the most critical hyperparameters of training. Typical values range from to , often with a schedule that decreases the learning rate over time.
Stochastic Gradient Descent (SGD)
In theory, you should compute the gradient over all training data at each step. With datasets of millions of examples, that's impractical. The solution: SGD. Instead of computing the exact gradient, you estimate it on a small random subset of the data, a mini-batch (typically 32 to 512 examples).
The estimated gradient is noisy, but on average it points in the right direction. This noise is actually beneficial: it helps escape local minima and generalize better.
Why all of this is fundamental in AI
Every time a neural network learns, the sequence is identical:
- Pass data through the network (forward pass)
- Compute the error between prediction and truth (loss)
- Compute the gradient of the loss with respect to each parameter (backward pass)
- Update the parameters in the direction opposite to the gradient
Steps 3 and 4 rely entirely on derivatives and gradients. Understanding the derivative means understanding how a neural network learns. The gradient is the signal that tells each weight in the network: "move a little in this direction, and the error will decrease."
Without derivatives, no gradients. Without gradients, no backpropagation. Without backpropagation, no deep learning. It's truly the mathematical foundation of all modern AI.
Key takeaways
- The derivative measures the rate of change of a function, the slope of the tangent
- The gradient generalizes the derivative to multiple dimensions, it's a vector pointing toward the steepest ascent
- Gradient descent consists of following the gradient in reverse to minimize the loss
- The learning rate controls step size, too small, too slow; too big, unstable
- SGD estimates the gradient on a mini-batch rather than the entire dataset, making large-scale training possible
- Knowing the derivatives of , , , and is essential for understanding the internal mechanisms of a neural network
Where this is used. The gradient is the only compass gradient descent has, and that procedure trains every model in this course.