<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/nn.py#L432-L458) |

Leaky version of a Rectified Linear Unit activation function.

#### View aliases


**Main aliases**

[`tf.keras.ops.nn.leaky_relu`](https://www.tensorflow.org/api_docs/python/tf/keras/ops/leaky_relu)

<br />

    tf.keras.ops.leaky_relu(
        x, negative_slope=0.2
    )

It allows a small gradient when the unit is not active, it is defined as:

`f(x) = alpha * x for x < 0` or `f(x) = x for x >= 0`.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `x` | Input tensor. |
| `negative_slope` | Slope of the activation function at x \< 0. Defaults to `0.2`. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A tensor with the same shape as `x`. ||

<br />

#### Example:

    x = np.array([-1., 0., 1.])
    x_leaky_relu = keras.ops.leaky_relu(x)
    print(x_leaky_relu)
    array([-0.2,  0. ,  1. ], shape=(3,), dtype=float64)