torch.nn.functional.glu¶ torch.nn.functional.glu(input, dim=-1) → Tensor[source][source]¶ 门控线性单元(Gated Linear Unit)。计算方式如下: GLU(a,b)=a⊗σ(b)\text{GLU}(a, b) = a \otimes \sigma(b) GLU(a,b)=a⊗σ(b)其中 input 沿 dim 维度被分成两半形成 a 和 b,σ\sigmaσ 是 sigmoid 函数,⊗\otimes⊗ 是矩阵的元素级乘积。 参见 Language Modeling with Gated Convolutional Networks。 参数 input (Tensor) – 输入张量 dim (int) – 沿此维度分割输入。默认值:-1 返回类型 Tensor