GLU¶ 类 torch.nn.GLU(dim=-1)[source][source]¶ 应用门控线性单元函数。 GLU(a,b)=a⊗σ(b){GLU}(a, b)= a \otimes \sigma(b)GLU(a,b)=a⊗σ(b) 其中 aaa 是输入矩阵的前一半,而 bbb 是后一半。 参数 dim (int) – 用于分割输入的维度。默认值: -1 形状 输入: (∗1,N,∗2)(\ast_1, N, \ast_2)(∗1,N,∗2) 其中 * 表示任意数量的额外维度 输出: (∗1,M,∗2)(\ast_1, M, \ast_2)(∗1,M,∗2) 其中 M=N/2M=N/2M=N/2 示例 >>> m = nn.GLU() >>> input = torch.randn(4, 2) >>> output = m(input)