快捷方式

torch.nn.functional.gelu

torch.nn.functional.gelu(input, approximate='none') Tensor

當 approximate 引數為 'none' 時,按元素應用以下函式 GELU(x)=xΦ(x)\text{GELU}(x) = x * \Phi(x)

其中 Φ(x)\Phi(x) 是高斯分佈的累積分佈函式。

當 approximate 引數為 'tanh' 時,Gelu 透過以下公式近似計算:

GELU(x)=0.5x(1+Tanh(2/π(x+0.044715x3)))\text{GELU}(x) = 0.5 * x * (1 + \text{Tanh}(\sqrt{2 / \pi} * (x + 0.044715 * x^3)))

參見 高斯誤差線性單元 (GELUs)

文件

查閱 PyTorch 的完整開發者文件

檢視文件

教程

獲取針對初學者和高階開發者的深度教程

檢視教程

資源

查詢開發資源並獲得問題解答

檢視資源