<br />

<button value="stable" default="">See Stable</button> <button value="nightly">See Nightly</button>

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/ops/core.py#L676-L697) |

Stops gradient computation.

```python
tf.keras.ops.stop_gradient(
    variable
)
```

<br />

<br />

<br />

| ## Args ||
|---|---|
| `variable` | A tensor variable for which the gradient computation is to be disabled. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| The variable with gradient computation disabled. ||

<br />

#### Examples:

```python
var = keras.backend.convert_to_tensor(
    [1., 2., 3.],
    dtype="float32"
)
var = keras.ops.stop_gradient(var)
```