Good to see you again. In the previous lesson, you used vectors and matrices to express the computations inside a model and checked that their shapes were compatible. We now add the complementary question: if an input or parameter changes slightly, how does an output change?
That question is central to learning from data. A speech model produces a loss value that summarizes its current error; derivatives and gradients describe how sensitive that loss is to each model parameter locally. This lesson develops the interpretation first. In the next lesson, you will calculate gradients of simple functions.
Derivatives: local change in one input
Start with a function having one input and one output:
A derivative measures the function’s instantaneous rate of change at a particular input. It answers:
If receives a very small nudge, what change should we expect in ?
Common notation includes:
and
The notation is suggestive: a tiny input change produces a corresponding tiny output change . It is not an ordinary fraction in the introductory interpretation, but it captures the ratio of local output change to local input change.
For a straight line, slope is constant everywhere. For a curved function, however, the slope can differ at every location. The derivative is the slope of the tangent line: the straight line that best approximates the curve in an extremely small neighborhood of the chosen point.
Derivative as a concept | Derivatives introduction | AP Calculus AB | Khan Academy
Watch “Derivative as a concept” from Khan Academy for the distinction between average change across an interval and local, instantaneous change at one point.
Begin at curved rates, where the video contrasts secant-line slopes with the changing slope of a curve. Then watch tangent intuition for the derivative as a tangent-line slope and instantaneous rate of change. Finish with derivative notation, focusing on the meanings of f'(x) and \frac{dy}{dx}, rather than on limit-based calculation.
Signs and magnitudes matter
At a point :
- If , a small increase in tends to increase .
- If , a small increase in tends to decrease .
- If , the graph is locally flat to first order.
The magnitude gives sensitivity. A derivative of means the output changes about ten times as much as the input, locally; a derivative near zero means the output is locally insensitive to that input.
A useful engineering form of the idea is the local linear approximation:
This does not say that a nonlinear function actually becomes a line. It says that for a sufficiently small , the tangent line provides a good prediction.
For example, suppose a loss-like function is
At , its derivative is
A positive derivative tells us that increasing slightly will increase the function. Conversely, decreasing slightly should decrease it. The derivative is a local statement: it describes what happens near , not necessarily after a very large change to .
Derivatives have units
If has units and has units, then the derivative has units of “output per input.”
For example, if is position in meters and is time in seconds, then
has units of meters per second: velocity.
In machine learning, the units are often abstract, but the same logic holds. If is a dimensionless loss and is a weight, then means local loss change per unit change in that weight.
From one input to many: partial derivatives
Machine-learning functions rarely depend on only one input. A loss may depend on millions or billions of parameters. Even a simple two-input function,
already needs a more precise question. If changes, is that because changed, changed, or both?
A partial derivative isolates one input direction while holding every other input fixed.
means: “How does change locally as changes while is held fixed?”
Similarly,
means: “How does change locally as changes while is held fixed?”
The curly symbol distinguishes partial derivatives from ordinary derivatives. It signals that the function has multiple inputs.
Imagine as a terrain map:
- and specify a horizontal position;
- gives the height at that position;
- is the slope when moving only east or west;
- is the slope when moving only north or south.
Each partial derivative tells only part of the local story, hence the name.
Consider the function
At the point :
while
Interpret these values before worrying about how to calculate them:
- Near , increasing by a small amount, with fixed, increases at a local rate of about per unit of .
- Near , increasing by a small amount, with fixed, changes at a different local rate.
The inputs need not matter equally. A function can be highly sensitive to one coordinate and almost insensitive to another.
Partial Derivatives and the Gradient of a Function
Watch Professor Dave Explains’ “Partial Derivatives and the Gradient of a Function” for a compact visual account of changing one coordinate at a time, then combining those coordinate-wise sensitivities.
Watch partial derivatives to see why one variable is held fixed while differentiating with respect to another. Then continue with the gradient, concentrating on the gradient as a vector of partial derivatives and its geometric meaning as maximum local increase.
Combining small changes
Suppose you are at a point where
If you make small simultaneous changes and , the total change is approximately
For instance, if
then
The positive movement in the direction tends to increase , but the movement in the negative direction decreases it more strongly. This is why knowing individual partial derivatives is useful, but not yet the whole picture.
The gradient: the complete first-order local picture
For a scalar-valued function with two inputs,
the gradient collects all partial derivatives into a vector:
The symbol , pronounced “del” or “nabla,” means “take the gradient.”
For a function of inputs,
the gradient is
This shape relationship is important:
A scalar function’s gradient has one component for every input component.
If a loss depends on a parameter vector , then
If the parameters are stored as a matrix , then the gradient with respect to that matrix has the same shape as . Every parameter needs its own local sensitivity.

Geometric interpretation
The gradient has two linked meanings:
- Direction: points in the direction of the steepest local increase in .
- Magnitude: is the largest possible local rate of increase per unit distance moved.
On a contour map, each contour joins points having the same function value. Moving along a contour does not change the function value, at least locally. Therefore, the gradient is perpendicular to the contour line and points across contours toward higher values.
The mountain image depicts this distinction. The gradient is the locally steepest uphill direction. A different direction can still go uphill, downhill, or stay level, but it generally changes the function less rapidly than the gradient direction.
The direction of steepest local decrease is
That negative gradient becomes important when training models: a loss is an error measure, so we normally seek a direction that decreases it rather than increases it.
Directional derivatives
A partial derivative measures change along one coordinate axis. But an input can move in any direction. For a unit direction vector , the directional derivative is
This is a dot product, connecting directly to the previous lesson.
The directional derivative answers:
If I move one unit in direction , what is the local rate of change in ?
Because it is a dot product:
- A positive value means that direction increases .
- A negative value means that direction decreases .
- A value of zero means the direction is locally level.
- The maximum possible value is , achieved when aligns with the gradient.
- The most negative value is , achieved when points opposite the gradient.
This makes the gradient more than a list of coordinate-wise numbers. It is the object that predicts first-order change in every direction.
Why gradients matter in speech ML
In a speech-recognition system, a model might transform log-mel frames into token probabilities. During training, the model compares those predictions to the transcript and produces a scalar loss:
Here, denotes all learned parameters: projection weights, convolution filters, attention matrices, normalization parameters, and more.
The gradient
answers a local sensitivity question for every parameter:
If this particular parameter increases slightly, how should the training loss change, with all other parameters held fixed?
A component with a positive gradient means increasing that parameter tends to increase loss locally. A component with a negative gradient means increasing it tends to reduce loss locally. The magnitude indicates how strongly the loss responds near the current parameter values.
For a model with a parameter matrix
the loss gradient has matching shape:
That shape is not incidental. It contains one sensitivity value for every learned weight connecting the 80 input features to the 256-dimensional representation.
In PyTorch, automatic differentiation will eventually compute these gradients. But software can only be used responsibly when its output has a clear interpretation: parameter.grad is not a mysterious set of numbers. It is a tensor of local loss sensitivities, aligned element-by-element with that parameter tensor.
Important cautions
| Statement | Correct interpretation |
|---|---|
| “The derivative is the change in a function.” | It is the local rate of change, not the total finite change over a large interval. |
| “A zero gradient means the minimum has been found.” | Not necessarily. It can be a local minimum, local maximum, saddle point, or flat region. |
| “A partial derivative tells how the function changes when all inputs change.” | No. It changes one input while holding the rest fixed. |
| “The gradient is a scalar slope.” | For a scalar output with many inputs, it is a vector of sensitivities. |
| “The gradient points toward the best solution.” | It points toward steepest increase. For loss minimization, the negative gradient is the relevant local direction. |
The word local is essential throughout. Gradients summarize behavior near the current point; they do not guarantee what will happen after a large parameter change or across a complicated nonconvex loss surface.
Key takeaways
- A derivative, or , measures instantaneous local change of a one-input function.
- A partial derivative, such as , measures local change with respect to one input while other inputs are fixed.
- The gradient, , is a vector containing all partial derivatives of a scalar-valued function.
- The gradient points in the direction of steepest local increase, and its norm gives the largest local increase rate per unit distance.
- The negative gradient points toward steepest local decrease, which is why gradients underpin model training.
- For a scalar loss, the gradient has the same shape as the input parameter tensor it differentiates with respect to.
Next, you will move from interpretation to computation: calculating gradients of simple multivariable functions by applying ordinary derivative rules one variable at a time.
Can't find a good explanation? Sign up and we'll make it for you
Sign up