hessian

Graph.hessian(tensor, variables, *, name=None)

Calculate a single Hessian matrix for all the variables.

The Hessian is a matrix containing all the second partial derivatives of the tensor with respect to the variables.

Parameters

  • tensor (Tensor) – The real scalar tensor TT whose Hessian matrix you want to calculate.
  • variables (list [Tensor ]) – The list of real variables {θi}\{\theta_i\} with respect to which you want to take the second partial derivatives of the tensor. If any of the tensors of the list is not scalar, this function treats each of the elements of the tensor as a different variable. It does this by flattening all tensors and concatenating them in the same sequence that you provided in this list.
  • name (str or None , optional) – The name of the node.

Returns

A 2D real Hessian matrix HH containing the second partial derivatives of the tensor TT with respect to the variables {θi}\{\theta_i\}.

Return type

Tensor

WARNING

This function currently doesn’t support calculating a Hessian matrix for a graph which includes an infidelity_pwc node if it involves a Hamiltonian with degenerate eigenvalues at any segment. In that case, the function returns a nan Hessian matrix.

Notes

The (i,j)(i,j) element of the Hessian contains the partial derivative of the tensor with respect to the ith and the jth variables:

Hi,j=2Tθiθj. H_{i,j} = \frac{\partial^2 T}{\partial \theta_i \partial \theta_j}.

The variables {θi}\{\theta_i\} follow the same sequence as the input list of variables. If some of the variables are not scalars, this function flattens them and concatenates them in the same order of the list of variables that you provided to create the sequence of scalar variables {θi}\{\theta_i\}.

If you choose a negative log-likelihood as the tensor TT, you can use this Hessian as an estimate of the Fisher information matrix.

Was this useful?