tlm_adjoint.hessian
Module Contents
- class tlm_adjoint.hessian.Hessian
Represents a Hessian associated with a given forward. Abstract base class.
- abstract compute_gradient(M, M0=None)
Compute the (conjugate of the) derivative of a functional with respect to a control using an adjoint.
- Parameters:
M – A variable or a
Sequence
of variables defining the control.M0 – A variable or a
Sequence
of variables defining the control value. M is used if not supplied.
- Returns:
The (conjugate of the) derivative. A variable or
Sequence
of variables, depending on the type of M.
- abstract action(M, dM, M0=None)
Compute (the conjugate of) a Hessian action on some \(\zeta\) using an adjoint of a tangent-linear. i.e. considering derivatives to be row vectors, compute
\[\left( \frac{d}{dm} \left[ \frac{d \mathcal{J}}{d m} \zeta \right] \right)^{*,T}.\]- Parameters:
M – A variable or a
Sequence
of variables defining the control.dM – A variable or a
Sequence
of variables defining \(\zeta\). The (conjugate of the) Hessian action on \(\zeta\) is computed.M0 – A variable or a
Sequence
of variables defining the control value. M is used if not supplied.
- Returns:
A tuple (J, dJ, ddJ). J is the value of the functional. dJ is the value of \(\left( d \mathcal{J} / d m \right) \zeta\). ddJ stores the (conjugate of the) result of the Hessian action on \(\zeta\), and is a variable or a
Sequence
of variables depending on the type of M.
- action_fn(m, m0=None)
Return a callable which can be used to compute Hessian actions.
- Parameters:
m – A variable defining the control.
m0 – A variable defining the control value. m is used if not supplied.
- Returns:
A callable which accepts a single variable argument, and returns the result of the Hessian action on that argument as a variable. Note that the result is not the conjugate of the Hessian action on the input argument.
- class tlm_adjoint.hessian.GeneralHessian(forward, *, manager=None)
Represents a Hessian associated with a given forward. Calls to
GeneralHessian.compute_gradient()
orGeneralHessian.action()
re-run the forward.- Parameters:
forward – A callable which accepts one or more variable arguments, and which returns a variable defining the forward functional.
manager – An
EquationManager
used to create an internal manager viaEquationManager.new()
. manager() is used if not supplied.
- compute_gradient(M, M0=None)
Compute the (conjugate of the) derivative of a functional with respect to a control using an adjoint.
- Parameters:
M – A variable or a
Sequence
of variables defining the control.M0 – A variable or a
Sequence
of variables defining the control value. M is used if not supplied.
- Returns:
The (conjugate of the) derivative. A variable or
Sequence
of variables, depending on the type of M.
- action(M, dM, M0=None)
Compute (the conjugate of) a Hessian action on some \(\zeta\) using an adjoint of a tangent-linear. i.e. considering derivatives to be row vectors, compute
\[\left( \frac{d}{dm} \left[ \frac{d \mathcal{J}}{d m} \zeta \right] \right)^{*,T}.\]- Parameters:
M – A variable or a
Sequence
of variables defining the control.dM – A variable or a
Sequence
of variables defining \(\zeta\). The (conjugate of the) Hessian action on \(\zeta\) is computed.M0 – A variable or a
Sequence
of variables defining the control value. M is used if not supplied.
- Returns:
A tuple (J, dJ, ddJ). J is the value of the functional. dJ is the value of \(\left( d \mathcal{J} / d m \right) \zeta\). ddJ stores the (conjugate of the) result of the Hessian action on \(\zeta\), and is a variable or a
Sequence
of variables depending on the type of M.
- class tlm_adjoint.hessian.GaussNewton(R_inv_action, B_inv_action=None)
Represents a Gauss-Newton approximation for a Hessian. Abstract base class.
In terms of matrices this defines a Hessian approximation
\[H = J^T R_\text{obs}^{-1} J + B^{-1},\]where \(J\) is the forward Jacobian. In a variational assimilation approach \(R_\text{obs}^{-1}\) corresponds to the observational inverse covariance and \(B^{-1}\) corresponds to the background inverse covariance.
- Parameters:
R_inv_action – A callable which accepts one or more variables, and returns the conjugate of the action of the operator corresponding to \(R_\text{obs}^{-1}\) on those variables, returning the result as a variable or a
Sequence
of variables.B_inv_action – A callable which accepts one or more variables, and returns the conjugate of the action of the operator corresponding to \(B^{-1}\) on those variables, returning the result as a variable or a
Sequence
of variables.
- action(M, dM, M0=None)
Compute (the conjugate of) a Hessian action on some \(\zeta\), using the Gauss-Newton approximation for the Hessian. i.e. compute
\[\left( H \zeta \right)^{*,T}.\]- Parameters:
M – A variable or a
Sequence
of variables defining the control.dM – A variable or a
Sequence
of variables defining \(\zeta\). The (conjugate of the) approximated Hessian action on \(\zeta\) is computed.M0 – A variable or a
Sequence
of variables defining the control value. M is used if not supplied.
- Returns:
The (conjugate of the) result of the approximated Hessian action on \(\zeta\). A variable or a
Sequence
of variables depending on the type of M.
- action_fn(m, m0=None)
Return a callable which can be used to compute Hessian actions using the Gauss-Newton approximation.
- Parameters:
m – A variable defining the control.
m0 – A variable defining the control value. m is used if not supplied.
- Returns:
A callable which accepts a single variable argument, and returns the result of the approximated Hessian action on that argument as a variable. Note that the result is not the conjugate of the approximated Hessian action on the input argument.
- class tlm_adjoint.hessian.GeneralGaussNewton(forward, R_inv_action, B_inv_action=None, *, manager=None)
Represents a Gauss-Newton approximation to a Hessian associated with a given forward. Calls to
GaussNewton.action()
re-run the forward.- Parameters:
forward – A callable which accepts one or more variable arguments, and which returns a variable or
Sequence
of variables defining the state.R_inv_action – See
GaussNewton
.B_inv_action – See
GaussNewton
.manager – An
EquationManager
used to create an internal manager viaEquationManager.new()
. manager() is used if not supplied.