評價此頁

GLU#

class torch.nn.modules.activation.GLU(dim=-1)[原始碼]#

應用門控線性單元函式。

GLU(a,b)=aσ(b){GLU}(a, b)= a \otimes \sigma(b) where aa is the first half of the input matrices and bb is the second half.

引數

dim (int) – the dimension on which to split the input. Default: -1

形狀
  • Input: (1,N,2)(\ast_1, N, \ast_2) where * means, any number of additional dimensions

  • Output: (1,M,2)(\ast_1, M, \ast_2) where M=N/2M=N/2

../_images/GLU.png

示例

>>> m = nn.GLU()
>>> input = torch.randn(4, 2)
>>> output = m(input)
extra_repr()[原始碼]#

返回模組的額外表示。

返回型別

str

forward(input)[原始碼]#

執行前向傳播。

返回型別

張量