liveBook · Manning

Jacfwd()

As explained in Deep Learning with JAX

A JAX function that computes a Jacobian by applying forward-mode differentiation repeatedly to input directions.

Computes a full Jacobian with forward-mode autodiff by sweeping over input directions. It returns the same values as jacrev(), but is usually better for tall Jacobians, where outputs outnumber inputs. section 4.2.5 section 4.3.2

Treat it as the forward-mode counterpart to jacrev(): one forward pass per input variable, with each pass contributing one Jacobian column. The treatment stops short of autodiff implementation internals. section 4.3.2 section 4.4

Use it when the Jacobian shape suggests forward mode fits better:

  • tall matrices, where outputs are significantly more numerous than inputs. section 4.2.5
  • near-square matrices, where it is described as probably better. section 4.2.5
  • functions with several inputs passed separately, using argnums to choose which parameter to differentiate. section 4.2.5

Vector-valued function Jacobian

For a two-output, three-input function, jacfwd(f)(jnp.array([3.0, 4.0, 5.0])) matches jacrev(f) and is measured faster in the example.

From Jacobian columns to Hessians

A Hessian can be built from jacfwd(grad(f)) or jacfwd(jacrev(f)), showing jacfwd() as a building block for higher-order derivatives.

How Deep Learning with JAX covers it

How deep it goes
Explains the forward-mode idea, one input direction per pass, and relates it to Jacobian columns and higher-order derivatives.
Examples
Uses a two-output, three-input function, timing output, and Hessian compositions.
What it assumes
Assumes familiarity with vector-valued functions, partial derivatives, and input-output shape reasoning.
What you can do after
Apply jacfwd() to compute Jacobians and reuse it in Hessian constructions.
How it connects
Connects to jacrev(), jvp(), grad(), and hessian().

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with JAX. The section links point to the parts of the book it draws on.