评价此页

GLU#

class torch.nn.GLU(dim=-1)[source]#

应用门控线性单元函数。

GLU(a;b)=aσ(b){GLU}(a; b)= a \otimes \sigma(b),其中 aa 是输入矩阵的前一半,bb 是后一半。

参数

dim (int) – 输入分割的维度。默认为 -1

形状
  • 输入:(1,N,2)(\ast_1, N, \ast_2),其中 * 表示任意数量的额外维度

  • 输出:(1,M,2)(\ast_1, M, \ast_2),其中 M=N/2M=N/2

../_images/GLU.png

示例

>>> m = nn.GLU()
>>> input = torch.randn(4, 2)
>>> output = m(input)