Vector–Jacobian products
A vector–Jacobian product propagates output sensitivity backward through the derivative of a vector operation.
On this page 8 sections
01Understand the idea#
A vector–Jacobian product combines a downstream sensitivity for each output into sensitivities for the inputs. It is the matrix form of a backward step. Instead of asking for the whole table of derivatives, it asks which weighted combination of those derivatives the current loss needs.
For , the Jacobian has one row per output and one column per input. Let be a column of output sensitivities. The input sensitivities form column :
With and , each input collects contributions from both outputs: and .
With output-row Jacobian rows and , and upstream row sensitivities , weight the first Jacobian row by 5 and the second by . Their sum is . The two resulting entries correspond to the two inputs.
; output sensitivity . Find input sensitivity.
Show answer and explanation
Use .
02If J has shape m× n, then s has m entries and J^Ts has n entries#
If has shape , then has entries and has entries. With row-vector sensitivities, the same calculation is written .
For , the backward rule can act coordinate by coordinate: input sensitivity is . No full diagonal matrix needs to be stored.
For , , output sensitivity . Find input sensitivity.
Show answer and explanation
Use : .
03J maps small input changes toward outputs#
maps small input changes toward outputs. Its transpose sends output sensitivities back toward inputs. For a square Jacobian, both products may fit the dimensions, so shape alone cannot choose the right direction.
The full backward product adds all output contributions for each input.
; output sensitivity . Used backward. Repair it.
Show answer and explanation
Use .
04A closer look#
Backpropagation can compute this product for each operation without storing a full model-wide Jacobian. Here the full small matrix is supplied so you can see the multiplication. Check the convention: an upstream row vector multiplies the output-row Jacobian on the left.
With column sensitivities, multiply by the Jacobian transpose; local rules can compute the product directly.
- Propagate a supplied output sensitivity through a vector operation.
Sources & further reading
- [1]JAX authors: The Autodiff Cookbook with JVP and VJP ↗JAX authors · Article