e3x.nn.activations.hard_tanh
- e3x.nn.activations.hard_tanh(x)[source]
Hard \(\mathrm{tanh}\) activation function.
Computes the gated linear activation with:
\[\begin{split}\mathrm{gate}(x) = \begin{cases} -\frac{1}{x}, & x < -1\\ 1, & -1 \le x \le 1\\ \frac{1}{x}, & 1 < x \end{cases}\end{split}\]For scalar inputs, this is equivalent to:
\[\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 (
Union[Float[Array, '... 1 (max_degree+1)**2 num_features'], Float[Array, '... 2 (max_degree+1)**2 num_features']]) – Input features to which the nonlinearity is applied.- Return type:
- Returns:
The result of applying the nonlinearity to the input features.