mlx.nn.gelu_fast_approx

mlx.nn.gelu_fast_approx#

class gelu_fast_approx(x)#

高斯誤差線性單元的快速近似版本。

精確計算請參見 gelu()

此函式在 \([-6, 6]\) 範圍內,以最大絕對誤差 \(< 0.015\) 近似 gelu,使用以下公式

\[x = x \sigma\left(1.702 x\right)\]

其中 \(\sigma(\cdot)\) 為 logistic sigmoid。

參考資料:- hendrycks/GELUs - https://arxiv.org/abs/1606.08415