Vector calculus extends standard calculus to multidimensional spaces. In machine learning and deep learning, most operations involve vectors, matrices, or tensors. Understanding vector-vector derivatives is crucial for algorithms like backpropagation.
Vector-Vector Derivative (The Jacobian)
When we have a vector-valued function that maps an -dimensional vector to an -dimensional vector , the derivative of with respect to is a matrix of partial derivatives called the Jacobian matrix.
Let and .
The Jacobian matrix of with respect to is an matrix defined as:
In numerator layout (the most common convention in ML), the -th entry of the Jacobian is:
- Row represents the gradient of the scalar output with respect to the input vector .
- Column represents how all output components change when the input component is perturbed.
Common Vector Derivatives
Here are some of the most common vector derivatives encountered in machine learning:
-
Linear transformation (Matrix-Vector multiplication): If , where is an matrix (independent of ), then:
-
Dot Product: If , where is a constant vector, the output is a scalar, so the Jacobian is a matrix (a row vector):
-
Quadratic Form: If , where is an matrix: If is symmetric, this simplifies to .
-
Pointwise / Element-wise Functions: If applies a scalar function element-wise to (e.g., an activation function like ReLU or Sigmoid), then . Because only depends on , all off-diagonal partial derivatives for are zero. The Jacobian is a diagonal matrix:
Chain Rule for Vectors
The multivariate chain rule is the foundation of Backpropagation in neural networks.
If we have nested vector functions and , then the composition is .
The Jacobian of with respect to is the matrix product of their individual Jacobians:
If , , and :
- is a Jacobian matrix.
- is an Jacobian matrix.
- The product is a matrix, which correctly matches the dimension of .
Application in Backpropagation
In deep learning, the final output (the loss) is a scalar. During backpropagation, we compute the gradient of the loss with respect to a layer’s weights or inputs. Let and . By the chain rule: Here, is a row vector (the gradient from the layer above), and is the Jacobian of the current layer. The result is a row vector, which is the gradient to pass down to the next layer.