Constructs the Hessian of sum of ys
with respect to x
in x
s.
Aliases:
tf.compat.v2.hessians
tf.hessians(
ys,
xs,
gate_gradients=False,
aggregation_method=None,
name='hessians'
)
hessians
() adds ops to the graph to output the Hessian matrix of ys
with respect to xs
. It returns a list of Tensor
of length len(xs
) where each tensor is the Hessian of sum(ys
).
The Hessian is a matrix of second-order partial derivatives of a scalar tensor (see https://en.wikipedia.org/wiki/Hessian_matrix for more details).
Args:
ys
: ATensor
or list of tensors to be differentiated.xs
: ATensor
or list of tensors to be used for differentiation.name
: Optionalname
to use for grouping all the gradient ops together. defaults to 'hessians'.colocate_gradients_with_ops
: Seegradients
() documentation for details.gate_gradients
: Seegradients
() documentation for details.- ``: See
gradients
() documentation for details.
Returns:
A list of Hessian matrices of sum(ys) for each x
in x
s.
Raises:
LookupError
: if one of the operations betweenxs
andys
does not have a registered gradient function.