# tf.compat.v1.hessians

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.14.0/tensorflow/python/ops/gradients_impl.py#L379-L443) |

Constructs the Hessian of sum of `ys` with respect to `x` in `xs`.

    tf.compat.v1.hessians(
        ys,
        xs,
        name='hessians',
        colocate_gradients_with_ops=False,
        gate_gradients=False,
        aggregation_method=None
    )

`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).

<br />

<br />

<br />

| ## Args ||
|---|---|
| `ys` | A `Tensor` or list of tensors to be differentiated. |
| `xs` | A `Tensor` or list of tensors to be used for differentiation. |
| `name` | Optional name to use for grouping all the gradient ops together. defaults to 'hessians'. |
| `colocate_gradients_with_ops` | See `gradients()` documentation for details. |
| `gate_gradients` | See `gradients()` documentation for details. |
| `aggregation_method` | See `gradients()` documentation for details. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A list of Hessian matrices of `sum(ys)` for each `x` in `xs`. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `LookupError` | if one of the operations between `xs` and `ys` does not have a registered gradient function. |

<br />