# tf.nn.relu6

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.13.1/tensorflow/python/ops/nn_ops.py#L3625-L3659) |

Computes Rectified Linear 6: `min(max(features, 0), 6)`.

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.nn.relu6`](https://www.tensorflow.org/api_docs/python/tf/nn/relu6)

<br />

    tf.nn.relu6(
        features, name=None
    )

In comparison with [`tf.nn.relu`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/nn/relu), relu6 activation functions have shown to
empirically perform better under low-precision conditions (e.g. fixed point
inference) by encouraging the model to learn sparse features earlier.
Source: [Convolutional Deep Belief Networks on CIFAR-10: Krizhevsky et al.,
2010](http://www.cs.utoronto.ca/%7Ekriz/conv-cifar10-aug2010.pdf).

#### For example:

    x = tf.constant([-3.0, -1.0, 0.0, 6.0, 10.0], dtype=tf.float32)
    y = tf.nn.relu6(x)
    y.numpy()
    array([0., 0., 0., 6., 6.], dtype=float32)

<br />

<br />

<br />

| ## Args ||
|---|---|
| `features` | A `Tensor` with type `float`, `double`, `int32`, `int64`, `uint8`, `int16`, or `int8`. |
| `name` | A name for the operation (optional). |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A `Tensor` with the same type as `features`. ||

<br />

<br />

<br />

<br />

| ## References ||
|---|---|
| Convolutional Deep Belief Networks on CIFAR-10: Krizhevsky et al., 2010 ([pdf](http://www.cs.utoronto.ca/%7Ekriz/conv-cifar10-aug2010.pdf)) ||

<br />