flax.linen.activation.hard_tanh

Contents

flax.linen.activation.hard_tanh#

flax.linen.activation.hard_tanh(x)[source]#

Hard \(\mathrm{tanh}\) activation function.

Computes the element-wise function:

\[\begin{split}\mathrm{hard\_tanh}(x) = \begin{cases} -1, & x < -1\\ x, & -1 \le x \le 1\\ 1, & 1 < x \end{cases}\end{split}\]
Parameters

x – input array

Returns

An array.