评价此页

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)[源代码]#

执行前向传播。

返回类型

张量