Gradients of Vector-Valued Functions
Formal
A vector field or a vector-valued function is a function .
For a function and a vector , the corresponding vector of function values is given by
Therefore, the partial derivative of a vector-valued function w.r.t. is given as vector
Note that the derivation in (2) is for . This could be generalized to a vector (-valued vector) by stacking .
(Jacobian)
The collection of all first-order partial derivatives of a vector-valued function is called the Jacobian. The Jacobian is an matrix, defined as follows
The gradient of with respect to is simply the matrix . This is the vector calculus equivalent of the simple scalar rule .
Intuition
Gradient of a scalar-valued function (), which is a vector that tells you the direction of steepest ascent. Now, consider a function that takes an -dimensional vector and outputs an -dimensional vector, .
The core question becomes more complex: “How does the entire output vector change when we slightly change one of the input variables?” And we must be able to answer this for every input variable.
Analogy: Imagine a sound mixing board. You have n input sliders (the vector x) that control m output meters (the vector f(x)).
- A scalar function’s gradient () would be like having all sliders control a single “master volume” meter. The gradient vector tells you which slider has the most impact on that single master volume.
- For a vector-valued function (), each of the sliders can affect all output meters, and each effect can have a different magnitude. We need a way to capture all these relationships simultaneously.
The Jacobian matrix is the object that does this. Each entry in the Jacobian matrix acts as a partial derivative that answers a specific question: “What is the rate of change of output meter with respect to a change in input slider ?” It captures the complete local linear behavior of the vector-to-vector mapping.
ML Applications
The Jacobian matrix is a cornerstone of multivariate calculus and appears in several critical areas of machine learning.
- Backpropagation in Neural Networks: Each layer of a neural network performs a vector-to-vector mapping (from the activations of the previous layer to its own activations). The Jacobian of this mapping is essential for the chain rule, allowing gradients to be propagated backward through the network. The matrix multiplication in the chain rule,
∂L/∂x = ∂L/∂a * ∂a/∂x, involves the Jacobian∂a/∂xof the current layer. - Change of Variables for Probability Distributions: When you transform a random variable via a function , the probability density of depends on the density of and how much stretches or compresses space. This local change in volume is measured by the determinant of the Jacobian of the transformation. This is critical for advanced generative models like normalizing flows.
- Local Linear Approximation: The Jacobian provides the best linear approximation of a complex vector-valued function near a point .
This is the multivariate equivalent of the first-order Taylor expansion and is used in advanced optimization algorithms.
Connections
- Forward Links: The Jacobian Determinant
- Backward Links: Partial Derivative, Univariate Calculus Refresher