Skip to main contentIBM Quantum Documentation
This page is from an old version of Qiskit SDK and does not exist in the latest version. We recommend you migrate to the latest version. See the release notes for more information.

Hessian

class Hessian(hess_method='param_shift', **kwargs)

GitHub

Bases: qiskit.opflow.gradients.hessian_base.HessianBase

Compute the Hessian of an expected value.

Parameters

  • hess_method (Union[str, CircuitGradient]) – The method used to compute the state/probability gradient. Can be either 'param_shift' or 'lin_comb' or 'fin_diff'. Ignored for gradients w.r.t observable parameters.
  • kwargs (dict) – Optional parameters for a CircuitGradient

Raises

ValueError – If method != fin_diff and epsilon is not None.


Methods Defined Here

convert

Hessian.convert(operator, params=None)

Parameters

  • operator (OperatorBase) – The operator for which we compute the Hessian
  • params (Union[Tuple[ParameterExpression, ParameterExpression], List[Tuple[ParameterExpression, ParameterExpression]], List[ParameterExpression], ParameterVector, None]) – The parameters we are computing the Hessian with respect to Either give directly the tuples/list of tuples for which the second order derivative is to be computed or give a list of parameters to build the full Hessian for those parameters. If not explicitly passed, the full Hessian is constructed. The parameters are then inferred from the operator and sorted by name.

Returns

An operator whose evaluation yields the Hessian

Return type

OperatorBase

get_hessian

Hessian.get_hessian(operator, params=None)

Get the Hessian for the given operator w.r.t. the given parameters

Parameters

Return type

OperatorBase

Returns

Operator which represents the gradient w.r.t. the given params.

Raises

  • ValueError – If params contains a parameter not present in operator.
  • ValueError – If operator is not parameterized.
  • OpflowError – If the coefficient of the operator could not be reduced to 1.
  • OpflowError – If the differentiation of a combo_fn requires JAX but the package is not installed.
  • TypeError – If the operator does not include a StateFn given by a quantum circuit
  • TypeError – If the parameters were given in an unsupported format.
  • Exception – Unintended code is reached
  • MissingOptionalLibraryError – jax not installed

Attributes

hess_method

Returns CircuitGradient.

Return type

CircuitGradient

Returns

CircuitGradient.

Was this page helpful?
Report a bug or request content on GitHub.