GELU¶
- class GELU(name=None)[源代码]¶
对每个元素应用函数:
\[\text{GELU}(x) = x\Phi(x)\]\(\Phi(x)\) 是高斯分布的累积分布函数 。
实际案例
import numpy as np import megengine as mge import megengine.module as M data = mge.tensor(np.array([-2,-1,0,1,2,]).astype(np.float32)) gelu = M.GELU() output = gelu(data) with np.printoptions(precision=4): print(output.numpy())
输出:
[-0.0455 -0.1587 0. 0.8413 1.9545]