Jacobians and Hessians
Gradients handle scalar outputs.
Some functions have vector outputs. For example:
The Jacobian collects partial derivatives for each output with respect to each input.
If a function has m outputs and n inputs, its Jacobian has shape m x n.
Rows correspond to outputs. Columns correspond to inputs.
Jacobian
For the function above:
The Jacobian tells how a small input change affects all outputs.
In local approximation form:
This is the vector-output version of the one-variable approximation
Delta f approx f'(x) Delta x.
At (x, y) = (3, 2), this becomes:
The entry in row 2, column 1 asks how output f_2 changes when input x
changes.
Hessian
The Hessian collects second derivatives of a scalar function.
It tells how the gradient changes.
For this course, keep the working meaning:
- gradient: local slope direction
- Hessian: local curvature information
For:
the gradient is [2x, 2y]. The Hessian is:
The diagonal entries say both directions curve upward at rate 2. The zero
off-diagonal entries say there is no mixed xy curvature in this simple
function.
ML Reading
Jacobians appear when outputs are vectors. Hessians appear in curvature, second-order optimization, and local analysis of loss surfaces.
Most deep learning training does not build full Hessians for large models. They are too large. But the idea matters: curvature tells how the gradient itself is changing.
For f(x, y) = [x + y, xy], what is partial f_2 / partial x?
Compute it first, then check your number.
Hint
f_2 = xy. Differentiate with respect to x, then use y = 2.
Solution
The second output is f_2 = xy. When differentiating with respect to x,
treat y as fixed, so:
partial(xy) / partial x = y
At the given point, y = 2, so the Jacobian entry is 2.
A function has 3 outputs and 2 inputs.
What is the shape of its Jacobian?
Answer it first, then check.
Hint
Rows correspond to outputs; columns correspond to inputs.
Solution
The Jacobian has one row per output and one column per input, so its shape is
3x2.
For f(x, y) = [x + y, xy], what is partial f_2 / partial y at x = 3?
Compute it first, then check your number.
Hint
f_2 = xy. Differentiate with respect to y.
Solution
The second output is f_2 = xy. When differentiating with respect to y,
treat x as fixed, so:
partial(xy) / partial y = x
At the given point, x = 3, so the entry is 3.
Does a Hessian describe how the gradient changes?
Answer it first, then check.
Hint
The Hessian collects second derivatives.
Solution
Yes. The Hessian describes local curvature, which means it describes how the gradient changes near a point.
A function has vector output and local approximation Delta f approx J Delta x.
Enter 1 if the Jacobian acts like the local linear map from input changes to
output changes.
Compute it first, then check your number.
Hint
Compare with Delta f approx f'(x) Delta x for one-variable functions.
Solution
Enter 1. For vector-output functions, the Jacobian is the local linear map
that approximates how small input changes affect the outputs.
Before Moving On
Jacobians track vector-output sensitivity. Hessians track curvature.