forked from mindspore-Ecosystem/mindspore
[OP] modify docs for hardshrink, meshgrid
This commit is contained in:
parent
e960f5beb7
commit
6e32fe1fb2
|
@ -45,6 +45,7 @@ functional算子是经过初始化后的Primitive,可以直接作为函数使
|
|||
:template: classtemplate.rst
|
||||
|
||||
mindspore.ops.fast_gelu
|
||||
mindspore.ops.hardshrink
|
||||
mindspore.ops.tanh
|
||||
|
||||
数学运算算子
|
||||
|
@ -266,6 +267,7 @@ Array操作
|
|||
mindspore.ops.gather_d
|
||||
mindspore.ops.gather_nd
|
||||
mindspore.ops.masked_select
|
||||
mindspore.ops.meshgrid
|
||||
mindspore.ops.nonzero
|
||||
mindspore.ops.one_hot
|
||||
mindspore.ops.range
|
||||
|
|
|
@ -452,6 +452,31 @@ mindspore.Tensor
|
|||
Tensor,是一个与此Tensor相同数据类型的输出矩阵。当此Tensor shape为 :math:`(*B, m)` , `x` shape为 :math:`(*B, n)` ,
|
||||
那么输出shape为 :math:`(*B, m, n)` 。
|
||||
|
||||
.. py:method:: hardshrink(lambd=0.5)
|
||||
|
||||
Hard Shrink激活函数,按输入元素计算输出,公式定义如下:
|
||||
|
||||
.. math::
|
||||
\text{HardShrink}(x) =
|
||||
\begin{cases}
|
||||
x, & \text{ if } x > \lambda \\
|
||||
x, & \text{ if } x < -\lambda \\
|
||||
0, & \text{ otherwise }
|
||||
\end{cases}
|
||||
|
||||
**参数:**
|
||||
|
||||
- **lambd** (float) - Hard Shrink公式定义的阈值 :math:`\lambda` 。默认值:0.5。
|
||||
|
||||
**返回:**
|
||||
|
||||
Tensor,shape和数据类型与输入相同。
|
||||
|
||||
**异常:**
|
||||
|
||||
- **TypeError** - `lambd` 不是float。
|
||||
- **TypeError** - 原始Tensor的dtype既不是float16也不是float32。
|
||||
|
||||
.. py:method:: has_init
|
||||
:property:
|
||||
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
mindspore.ops.HShrink
|
||||
=====================
|
||||
|
||||
.. py:class:: mindspore.ops.HShrink
|
||||
|
||||
Hard Shrink激活函数。
|
||||
|
||||
更多参考详见 :func:`mindspore.ops.hardshrink`。
|
|
@ -1,25 +1,8 @@
|
|||
mindspore.ops.Meshgrid
|
||||
========================
|
||||
======================
|
||||
|
||||
.. py:class:: mindspore.ops.Meshgrid(indexing="xy")
|
||||
.. py:class:: mindspore.ops.Meshgrid(indexing='xy')
|
||||
|
||||
从给定的Tensor生成网格矩阵。
|
||||
从给定的Tensor生成网格矩阵。给定N个一维Tensor,对每个Tensor做扩张操作,返回N个N维的Tensor。
|
||||
|
||||
给定N个一维Tensor,对每个Tensor做扩张操作,返回N个N维的Tensor。
|
||||
|
||||
**参数:**
|
||||
|
||||
- **indexing** ('xy', 'ij', optional) - 'xy'或'ij'。以笛卡尔坐标'xy'或者矩阵'ij'索引作为输出。以长度为 `M` 和 `N` 的二维输入,取值为'xy'时,输出的shape为 :math:`(N, M)` ,取值为'ij'时,输出的shape为 :math:`(M, N)` 。以长度为 `M` , `N` 和 `P` 的三维输入,取值为'xy'时,输出的shape为 :math:`(N, M, P)` ,取值为'ij'时,输出的shape为 :math:`(M, N, P)` 。默认值:'xy'。
|
||||
|
||||
**输入:**
|
||||
|
||||
- **input** (Union[tuple]) - N个一维Tensor。输入的长度应大于1。数据类型为Number。
|
||||
|
||||
**输出:**
|
||||
|
||||
Tensor,N个N维tensor对象的元组。数据类型与输入相同。
|
||||
|
||||
**异常:**
|
||||
|
||||
- **TypeError** - `indexing` 不是str或 `input` 不是元组。
|
||||
- **ValueError** - `indexing` 的取值既不是'xy'也不是'ij'。
|
||||
更多参考详见 :func:`mindspore.ops.meshgrid`。
|
|
@ -0,0 +1,28 @@
|
|||
mindspore.ops.hardshrink
|
||||
========================
|
||||
|
||||
.. py:function:: mindspore.ops.hardshrink(x, lambd=0.5)
|
||||
|
||||
Hard Shrink激活函数,按输入元素计算输出,公式定义如下:
|
||||
|
||||
.. math::
|
||||
\text{HardShrink}(x) =
|
||||
\begin{cases}
|
||||
x, & \text{ if } x > \lambda \\
|
||||
x, & \text{ if } x < -\lambda \\
|
||||
0, & \text{ otherwise }
|
||||
\end{cases}
|
||||
|
||||
**参数:**
|
||||
|
||||
- **x** (Tensor) - Hard Shrink的输入,数据类型为float16或float32。
|
||||
- **lambd** (float) - Hard Shrink公式定义的阈值 :math:`\lambda` 。默认值:0.5。
|
||||
|
||||
**输出:**
|
||||
|
||||
Tensor,shape和数据类型与输入相同。
|
||||
|
||||
**异常:**
|
||||
|
||||
- **TypeError** - `lambd` 不是float。
|
||||
- **TypeError** - `x` 的dtype既不是float16也不是float32。
|
|
@ -0,0 +1,22 @@
|
|||
mindspore.ops.meshgrid
|
||||
======================
|
||||
|
||||
.. py:function:: mindspore.ops.meshgrid(inputs, indexing='xy')
|
||||
|
||||
从给定的Tensor生成网格矩阵。
|
||||
|
||||
给定N个一维Tensor,对每个Tensor做扩张操作,返回N个N维的Tensor。
|
||||
|
||||
**参数:**
|
||||
|
||||
- **inputs** (Union[tuple]) - N个一维Tensor。输入的长度应大于1。数据类型为Number。
|
||||
- **indexing** ('xy', 'ij', optional) - 'xy'或'ij'。以笛卡尔坐标'xy'或者矩阵'ij'索引作为输出。以长度为 `M` 和 `N` 的二维输入,取值为'xy'时,输出的shape为 :math:`(N, M)` ,取值为'ij'时,输出的shape为 :math:`(M, N)` 。以长度为 `M` , `N` 和 `P` 的三维输入,取值为'xy'时,输出的shape为 :math:`(N, M, P)` ,取值为'ij'时,输出的shape为 :math:`(M, N, P)` 。默认值:'xy'。
|
||||
|
||||
**输出:**
|
||||
|
||||
Tensor,N个N维tensor对象的元组。数据类型与输入相同。
|
||||
|
||||
**异常:**
|
||||
|
||||
- **TypeError** - `indexing` 不是str或 `inputs` 不是元组。
|
||||
- **ValueError** - `indexing` 的取值既不是'xy'也不是'ij'。
|
|
@ -45,6 +45,7 @@ Activation Functions
|
|||
:template: classtemplate.rst
|
||||
|
||||
mindspore.ops.fast_gelu
|
||||
mindspore.ops.hardshrink
|
||||
mindspore.ops.tanh
|
||||
|
||||
Mathematical Operators
|
||||
|
@ -267,6 +268,7 @@ Array Operation
|
|||
mindspore.ops.gather_nd
|
||||
mindspore.ops.one_hot
|
||||
mindspore.ops.masked_select
|
||||
mindspore.ops.meshgrid
|
||||
mindspore.ops.nonzero
|
||||
mindspore.ops.range
|
||||
mindspore.ops.rank
|
||||
|
|
|
@ -1718,11 +1718,11 @@ def meshgrid(inputs, indexing='xy'):
|
|||
case with inputs of length `M`, `N` and `P`, outputs are of shape
|
||||
`(N, M, P)` for 'xy' indexing and `(M, N, P)` for 'ij' indexing.
|
||||
|
||||
Outputs:
|
||||
Returns:
|
||||
Tensors, A Tuple of N N-D Tensor objects. The data type is the same with the Inputs.
|
||||
|
||||
Raises:
|
||||
TypeError: If `indexing` is not a str or `input` is not a tuple.
|
||||
TypeError: If `indexing` is not a str or `inputs` is not a tuple.
|
||||
ValueError: If `indexing` is neither 'xy' nor 'ij'.
|
||||
|
||||
Supported Platforms:
|
||||
|
|
Loading…
Reference in New Issue