TensorPlay
latest (dev)
Copy
View Markdown

Latest development documentation · Updated 2026-10-08

tensorplay.func.hessian

tensorplay.func.hessian(func: Callable, argnums: int | tuple[int, ...] = 0)

Returns a function computing the Hessian of func.

Built as the reverse-mode jacobian of the reverse-mode gradient. The forward-over-reverse ordering would need tangents to flow through the backward pass itself, which this engine’s reverse mode does not carry; reverse-over-reverse composes two plain jacobians instead.

Example

>>> def f(x):
...     return x.sin().sum()
>>> hess = hessian(f)(tensorplay.randn(5))
>>> hess.shape
tensorplay.Size(5, 5)

On this page

Ask DeepWiki