!43996 fix doc of glu

Merge pull request !43996 from lianliguang/code_docs_ms
This commit is contained in:
i-robot 2022-10-18 01:04:40 +00:00 committed by Gitee
commit af9e68c5eb
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 19 additions and 14 deletions

View File

@ -12,10 +12,10 @@ mindspore.nn.GLU
其中,:math:`a` 表示输入Tensor的前一半元素:math:`b` 表示输入Tensor的另一半元素。
参数:
- **axis** (int) - 指定分割轴。数据类型为整型,默认值:0
- **axis** (int) - 指定分割轴。数据类型为整型,默认值:-1
输入:
- **x** (Tensor) - Tensor的shape为 (x_1, x_2, ..., x_R)。x必须在axis 轴能够被平均分成两份。
- **x** (Tensor) - Tensor的shape为 :math:`(\ast_1, N, \ast_2)``x` 必须在 `axis` 轴能够被平均分成两份。
输出:
Tensor数据类型与输入 x 相同shape等于 x 按照 axis 拆分后的一半。
Tensor数据类型与输入 `x` 相同shape等于 `x` 按照 `axis` 拆分后的一半。

View File

@ -12,11 +12,11 @@ mindspore.ops.glu
其中,:math:`a` 表示输入input_x 拆分后 Tensor的前一半元素:math:`b` 表示输入拆分Tensor的另一半元素。
参数:
- **axis** (int) - 指定分割轴。数据类型为整型默认值0
- **x** (Tensor) - Tensor的shape为 (x_1, x_2, ..., x_R) 。x 必须在axis 轴能够被平均分成两份
- **x** (Tensor) - :math:`(\ast_1, N, \ast_2)``x` 必须在 `axis` 轴能够被平均分成两份
- **axis** (int) - 指定分割轴。数据类型为整型,默认值:-1
返回:
Tensor数据类型与输入 x 相同shape等于 x 按照axis 拆分后的一半。
Tensor数据类型与输入 `x` 相同shape等于 `x` 按照 `axis` 拆分后的一半。
异常:
- **TypeError** - `x` 数据类型不是Number。

View File

@ -1498,18 +1498,21 @@ class GLU(Cell):
axis (int): the dimension on which to split the input. Default: -1
Inputs:
- **x** (Tensor) - :math:`(\ast_1, N, \ast_2)` where `*` means, any number of additional dimensions
- **x** (Tensor) - :math:`(\ast_1, N, \ast_2)` where `*` means, any number of additional dimensions.
Outputs:
Tensor, :math:`(\ast_1, M, \ast_2)` where :math:`M=N/2`
Tensor, :math:`(\ast_1, M, \ast_2)` where :math:`M=N/2`, with the same dtype as the `x`.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> m = nn.GLU()
>>> input = Tensor(np.randomn.randn(4, 2))
>>> input = Tensor([[0.1,0.2,0.3,0.4],[0.5,0.6,0.7,0.8]])
>>> output = m(input)
>>> print(out)
[[0.05744425 0.11973753
[0.33409387 0.41398472]]
"""
def __init__(self, axis=-1):

View File

@ -3142,10 +3142,10 @@ def glu(x, axis=-1):
Args:
x (Tensor): :math:`(\ast_1, N, \ast_2)` where `*` means, any number of additional dimensions
axis (int): the dimension on which to split the input. Default: -1
axis (int): the dimension on which to split the input. Default: -1.
Returns:
Tensor of shape :math:`(\ast_1, M, \ast_2)` where :math:`M=N/2`, with the same dtype and shape as the `x`.
Tensor of shape :math:`(\ast_1, M, \ast_2)` where :math:`M=N/2`, with the same dtype as the `x`.
Raises:
TypeError: If dtype of `x` is not a number.
@ -3155,9 +3155,11 @@ def glu(x, axis=-1):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> m = nn.GLU()
>>> input = Tensor(np.randomn.randn(4, 2))
>>> output = m(input)
>>> input = Tensor([[0.1,0.2,0.3,0.4],[0.5,0.6,0.7,0.8]])
>>> output = ops.glu(input)
>>> print(out)
[[0.05744425 0.11973753
[0.33409387 0.41398472]]
"""
if not isinstance(x, Tensor) or x.size == 0:
raise RuntimeError("glu does not support scalars because halving size must be even")