mlx_rs::nn

Function gelu_approximate

Source
pub fn gelu_approximate(x: impl AsRef<Array>) -> Result<Array>
Expand description

An approximation to Gaussian Error Linear Unit.

This is:

0.5 * x * (1 + tanh(sqrt(2 / PI) * (x + 0.044715 * x ** 3)))