mindspore.mint.nn.functional.glu ================================ .. image:: https://mindspore-website.obs.cn-north-4.myhuaweicloud.com/website-images/master/resource/_static/logo_source.svg :target: https://gitee.com/mindspore/mindspore/blob/master/docs/api/api_python/mint/mindspore.mint.nn.functional.glu.rst :alt: 查看源文件 .. py:function:: mindspore.mint.nn.functional.glu(input, dim=-1) 计算输入Tensor的门线性单元激活函数(Gated Linear Unit activation function)值。 .. math:: {GLU}(a, b)= a \otimes \sigma(b) 其中,:math:`a` 表示输入Tensor `input` 拆分后的前一半元素, :math:`b` 表示 `input` 拆分后的另一半元素。 其中 :math:`\sigma` 是sigmoid函数, :math:`\otimes` 是Hadamard乘积。 请参考 `Language Modeling with Gated Convluational Networks <https://arxiv.org/abs/1612.08083>`_ 。 参数: - **input** (Tensor) - 待计算的Tensor,数据类型为浮点型,shape为 :math:`(\ast_1, N, \ast_2)` ,其中 `*` 为任意额外维度,且要求 :math:`N` 为偶数。 :math:`N` 为 `input` 在被 `dim` 选中的维度上的大小。 - **dim** (int,可选) - 指定分割 `input` 的轴,取值范围 `[-r, r)` ,其中 `r` 为 `input` 的维度数。默认值: ``-1`` ,输入 `input` 的最后一维。 返回: Tensor,数据类型与输入 `input` 相同,shape为 :math:`(\ast_1, M, \ast_2)`,其中 :math:`M=N/2` 。 异常: - **TypeError** - `input` 不是Tensor或 `dim` 不是整型。 - **IndexError** - `dim` 的值超出了 `[-r, r)` 的范围,其中 `r` 为 `input` 的维度数。 - **RuntimeError** - `input` 数据类型不被支持。 - **RuntimeError** - `input` 在被 `dim` 选中的维度上的长度不为偶数。