<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#L445-L459) |

Hard Shrink activation function.

    tf.keras.activations.hard_shrink(
        x, threshold=0.5
    )

#### It is defined as:

`hard_shrink(x) = x` if `|x| > threshold`,
`hard_shrink(x) = 0` otherwise.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `x` | Input tensor. |
| `threshold` | Threshold value. Defaults to 0.5. |

<br />