Multivariable chain rule
For differentiable vector maps in output-row convention, the composition Jacobian is the outer Jacobian at the inner output times the inner Jacobian at the original input.
On this page 9 sections
01Understand the idea#
When several intermediate variables all depend on an input, that input can affect the final output along several paths. The multivariable chain rule adds the contributions from those paths. Multiplication carries a rate along one path; addition combines different paths.
For , the inner map acts first. The outer map receives , so its derivative must be evaluated there.
For differentiable maps, multiply the outer Jacobian by the inner Jacobian. We use output rows and input columns.
Let , , and . At , the forward values are . Through , the contribution is . Through , it is . Adding gives .
rows: . rows: . Return the ordered rows of .
Show answer and explanation
: .
02Let G(x,y)=(2x,y) and F(u,v)=(u^2,v)#
Let and . At , first find the intermediate input.
For and at , inner diagonal entries are 2,1. At , outer entries are 4,1. Multiply to get 8,1.
, . At , give as ordered rows.
Show answer and explanation
Outer entry: .
03A closer look#
If has 2 inputs and 3 outputs, and has 3 inputs and 2 outputs, the Jacobians have shapes and . Outer times inner gives the required result. Square factors still need the same order.
rows: . rows: . Repair reversed factors: give as ordered rows.
Show answer and explanation
: .
04A parameter may influence several intermediate model values before they meet in the loss#
A parameter may influence several intermediate model values before they meet in the loss. Omitting a path gives an incomplete gradient. When the same dependence is written using Jacobians, matrix multiplication performs these multiply-and-add operations with the dimensions kept in order.
Evaluate the intermediate input, then multiply outer by inner.
- Compute the derivative of a composed vector map using Jacobians.
Further questions
Why does the inner factor sit on the right?
Sources & further reading
- [1]MIT 18.S096, Lecture 1–2: Derivatives as Linear Operators ↗MIT OpenCourseWare · Course