Gaussian Error Linear Unit (GELU)#
API#
- class warp_nn.modules.activations.GELU( )[source]#
Bases:
ModuleGaussian Error Linear Unit (GELU) activation function.
This class computes the element-wise GELU activation function:
\[\text{GELU}(x) = x \, \Phi(x) = \frac{x}{2} \left(1 + \text{erf}\left(\frac{x}{\sqrt{2}}\right)\right)\]where \(\Phi(x)\) is the cumulative distribution function of the standard normal distribution. If
approximateis"tanh", the function is estimated with:\[\text{GELU}(x) \approx \frac{x}{2} \left(1 + \tanh\left(\sqrt{2 / \pi} \, (x + 0.044715 \, x^3)\right)\right)\]- Parameters:
approximate – The approximation algorithm to use:
"none"(exact computation) or"tanh".requires_grad – Whether the cached output arrays of the module require gradients.
- Raises:
ValueError – If the approximation algorithm is not supported.