hessian

Contents

hessian#

class pinnx.grad.hessian(fn, xs, y=None, xi=None, xj=None, vmap=True)[source]#

Compute Hessian matrix H as H[i, j] = d^2y / dx_i dx_j, where i,j = 0, …, dim_x - 1.

Parameters:
  • fn (Callable) – Function to compute the gradient.

  • xs (Dict) – Inputs of the function.

  • y (Union[str, Sequence[str], None]) – The output variable.

  • xi (Union[str, Sequence[str], None]) – i`th row. If `i is None, returns the j`th column H[:, `j].

  • xj (Union[str, Sequence[str], None]) – j`th column. If `j is None, returns the i`th row H[`i, :], i.e., the gradient of y_i. i and j cannot be both None, unless H has only one element, which is returned.

Returns:

H[i, j].