<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/activations/activations.py#L430-L442) |

HardTanh activation function.

    tf.keras.activations.hard_tanh(
        x
    )

#### It is defined as:

`hard_tanh(x) = -1 for x < -1`,
`hard_tanh(x) = x for -1 <= x <= 1`,
`hard_tanh(x) = 1 for x > 1`.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `x` | Input tensor. |

<br />