# tf_agents.bandits.policies.linalg.conjugate_gradient

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/bandits/policies/linalg.py#L41-L111) |

Returns `X` such that `A * X = B`.

    tf_agents.bandits.policies.linalg.conjugate_gradient(
        a_mat: https://www.tensorflow.org/agents/api_docs/python/tf_agents/typing/types/Tensor,
        b_mat: https://www.tensorflow.org/agents/api_docs/python/tf_agents/typing/types/Tensor,
        tol: float = 1e-10
    ) -> https://www.tensorflow.org/agents/api_docs/python/tf_agents/typing/types/Float

Implements the Conjugate Gradient method.
<https://en.wikipedia.org/wiki/Conjugate_gradient_method>

<br />

<br />

<br />

| ## Args ||
|---|---|
| `a_mat` | a Symmetric Positive Definite matrix, represented as a `Tensor` of shape `[n, n]`. |
| `b_mat` | a `Tensor` of shape `[n, k]`. |
| `tol` | (float) desired tolerance on the residual. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| `X` | `Tensor` `X` of shape `[n, k]` such that `A * X = B`. |

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `ValueError` | if `a_mat` is not square or `a_mat` and `b_mat` have incompatible shapes. |

<br />