快捷方式

GLU

torch.nn.GLU(dim=-1)[source][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

示例

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

文档

访问 PyTorch 的全面开发者文档

查看文档

教程

获取面向初学者和高级开发者的深度教程

查看教程

资源

查找开发资源并获得问题解答

查看资源