latest (dev)
Copy
Latest development documentation · Updated 2026-10-08
tensorplay.func.jacrev
- tensorplay.func.jacrev(func: Callable, argnums: int | tuple[int, ...] = 0, *, has_aux: bool = False, chunk_size: int | None = None, _preallocate_and_copy: bool = False)
Returns a function computing the Jacobian of
funcby reverse mode.Reverse mode costs one backward pass per output element, so
jacrevis the cheaper direction when the output is smaller than the input.- Parameters:
func (Callable) – a Python function returning one or more tensors.
argnums (int or Tuple[int]) – which positional arguments to differentiate with respect to. Default: 0.
has_aux (bool) – whether
funcreturns(output, aux).chunk_size (int, optional) – compute the Jacobian
chunk_sizerows at a time to bound peak memory.Nonecomputes it in one shot.
Example
>>> jacobian = jacrev(tensorplay.sin)(tensorplay.randn(5)) >>> jacobian.shape tensorplay.Size(5, 5)
Help improve this page
Found an error, an unclear step, or a missing example?
Was this page helpful?

