Skip to content
Glacius
CalculusConcept reference

Vector–Jacobian products

A vector–Jacobian product propagates output sensitivity backward through the derivative of a vector operation.

On this page 8 sections
  1. Overview
  2. Understand the idea
  3. If J has shape m× n, then s has m entries and J^Ts has n entries
  4. J maps small input changes toward outputs
  5. A closer look
  6. Key takeaway
  7. Sources & further reading
  8. Concept connections

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 y=f(x)y=f(x), the Jacobian JJ has one row per output and one column per input. Let ss be a column of output sensitivities. The input sensitivities form column gg:

g=JTsg=J^Ts

With J=[2103]J=\begin{bmatrix}2&1\\0&3\end{bmatrix} and s=(4,1)Ts=(4,-1)^T, each input collects contributions from both outputs: 2(4)+0(1)=82(4)+0(-1)=8 and 1(4)+3(1)=11(4)+3(-1)=1.

Column-vector sensitivity convention. A Jacobian with rows [2,1] and [0,3] maps input changes to output changes. For output sensitivity [4,-1], its transpose sends sensitivity [8,1] back to the inputs: 2×4+0×(-1)=8 and 1×4+3×(-1)=1. Layout is schematic.Column-vector sensitivity convention. A Jacobian with rows [2,1] and [0,3] maps input changes to output changes. For output sensitivity [4,-1], its transpose sends sensitivity [8,1] back to the inputs: 2×4+0×(-1)=8 and 1×4+3×(-1)=1. Layout is schematic.
Figure 1Column-vector sensitivity convention. A Jacobian with rows [2,1] and [0,3] maps input changes to output changes. For output sensitivity [4,-1], its transpose sends sensitivity [8,1] back to the inputs: 2×4+0×(-1)=8 and 1×4+3×(-1)=1. Layout is schematic.
Link to this figure ↗Download SVGDownload PNG

With output-row Jacobian rows (2,1)(2,1) and (3,4)(3,4), and upstream row sensitivities (5,1)(5,-1), weight the first Jacobian row by 5 and the second by 1-1. Their sum is (10,5)+(3,4)=(7,1)(10,5)+(-3,-4)=(7,1). The two resulting entries correspond to the two inputs.

Check your reasoning

J=[1230]J=\begin{bmatrix}1&2\\3&0\end{bmatrix}; output sensitivity s=(2,1)Ts=(2, -1)^T. Find input sensitivity.

  1. A(0,6)T(0, 6)^T
  2. B(1,4)T(-1, 4)^T
  3. C(0,3)T(0, 3)^T
Show answer and explanation
(1,4)T(-1, 4)^T

Use JTsJ^Ts.

02If J has shape m× n, then s has m entries and J^Ts has n entries#

If JJ has shape m×nm\times n, then ss has mm entries and JTsJ^Ts has nn entries. With row-vector sensitivities, the same calculation is written sTJs^TJ.

For yi=xi2y_i=x_i^2, the backward rule can act coordinate by coordinate: input sensitivity ii is 2xisi2x_i s_i. No full diagonal matrix needs to be stored.

Check your reasoning

For yi=xi2y_i=x_i^2, x=(3,2)Tx=(3, 2)^T, output sensitivity s=(1,4)Ts=(-1, 4)^T. Find input sensitivity.

  1. A(6,4)T(6, 4)^T
  2. B(24,4)T(24, -4)^T
  3. C(6,16)T(-6, 16)^T
Show answer and explanation
(6,16)T(-6, 16)^T

Use 2xisi2x_i s_i: (6,16)T(-6, 16)^T.

03J maps small input changes toward outputs#

JJ 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.

Check your reasoning

J=[3211]J=\begin{bmatrix}3&2\\1&-1\end{bmatrix}; output sensitivity s=(2,3)Ts=(2, 3)^T. Used JsJs backward. Repair it.

  1. A(9,1)T(9, 1)^T
  2. B(12,1)T(12, -1)^T
  3. C(10,0)T(10, 0)^T
Show answer and explanation
(9,1)T(9, 1)^T

Use JTsJ^Ts.

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.

Key takeaway

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. [1]

Reference this concept

Link to this page, a section, or an individual figure.

Glacius. “Vector–Jacobian products.” Math behind ML. /learn/c-vjp