!44959 q3 collective review part3

Merge pull request !44959 from 李林杰/code_docs_1101_q3_doc_collective_review_part3_master
This commit is contained in:
i-robot 2022-11-03 08:43:30 +00:00 committed by Gitee
commit 446bf7da80
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
44 changed files with 194 additions and 170 deletions

View File

@ -6,24 +6,24 @@ mindspore.ops.CropAndResize
从输入图像Tensor中提取切片并调整其大小。
.. note::
如果输出shape依赖于 `crop_size` 的值,则 `crop_size` 必须为常量。
如果输出shape依赖于 `crop_size` 的值,则 `crop_size` 必须为常量。目前该算子仅在 `method` 为"bilinear"支持反向, 其他方法将直接返回0。
参数:
- **method** (str, 可选) - 指定调整大小的采样方法,为可选字符串。提供的方法有:"bilinear"、"nearest"或"bilinear_v2"。"bilinear"代表标准双线性插值算法,而"bilinear_v2"在某些情况下可能会产生更好的结果。默认值:"bilinear"。
- **method** (str, 可选) - 指定调整大小的采样方法,为可选字符串。提供的方法有:"bilinear"、"nearest"或"bilinear_v2"。"bilinear"代表标准双线性插值算法,"nearest"代表最近邻差值算法,而"bilinear_v2"在某些情况下可能会产生更好的结果。默认值:"bilinear"。
- **extrapolation_value** (float, 可选) - 外插值数据类型为float。默认值0.0。
输入:
- **x** (Tensor) - 输入为四维的Tensor其shape必须是 :math:`(batch, image\_height, image\_width, depth)` 。支持的数据类型int8、int16、int32、int64、float16、float32、float64、uint8、uint16。
- **boxes** (Tensor) - 二维Tensor其shape为 :math:`(num\_boxes, 4)` 。第i行表示 `box_index[i]` 图像区域的坐标,并且坐标[y1, x1, y2, x2]是归一化后的值。归一化后的坐标值y映射到图像y * (image_height - 1)处,因此归一化后的图像高度范围为[0, 1],映射到实际图像高度范围为[0, image_height - 1]。我们允许y1 > y2在这种情况下视为原始图像的上下翻转变换。宽度尺寸的处理类似。坐标取值允许在[0, 1]范围之外,在这种情况下,我们使用 `extrapolation_value` 外插值进行补齐。支持的数据类型float32。
- **box_index** (Tensor) - `boxes` 的索引其shape为 :math:`(num\_boxes)` 的一维Tensor数据类型为int32取值范围为[0, batch)。box_index[i]的值表示第i个框的图像的值。
- **crop_size** (Tuple[int]) - 两个int32元素元素组成的tuple裁剪高度,裁剪宽度)。只能是常量。所有裁剪后的图像大小都将调整为此大小,且不保留图像内容的宽高比,裁剪高度和裁剪宽度都需要为正。
- **crop_size** (Tuple[int]) - 两个int32元素元素组成的tuplecrop_height, crop_width)。只能是常量。所有裁剪后的图像大小都将调整为此大小,且不保留图像内容的宽高比,裁剪高度和裁剪宽度都需要为正。
输出:
四维Tensor其shape为 :math:`(num\_boxes, crop\_height, crop\_width, depth)` 数据类型类型为float32。
异常:
- **TypeError** - `x``boxes``box_index` 不是Tensor。
- **TypeError** - `crop_size` 不是int32的2元组
- **TypeError** - `crop_size` 不是int32类型tuple`crop_size` 的长度不是2。
- **TypeError** - `boxes` 的数据类型不是float 或者,`box_index` 的数据类型不是int32。
- **TypeError** - `method` 不是字符串。
- **TypeError** - `extrapolation_value` 不是浮点值。

View File

@ -7,7 +7,7 @@ mindspore.ops.DivNoNan
`x1``x2` 的输入遵循隐式类型转换规则,使数据类型一致。
输入必须是两个Tensor或一个Tensor和一个Scalar。
当输入是两个Tensor时它们的dtype不能同时是布尔型的它们的shape可以广播。
当输入是两个Tensor时它们的dtype不能同时是bool类型的它们的shape可以广播。
当输入是一个Tensor和一个Scalar时Scalar只能是一个常数。
.. math::
@ -17,7 +17,7 @@ mindspore.ops.DivNoNan
\end{cases}
输入:
- **x1** (Union[Tensor, number.Number, bool]) - 第一个输入是number.Number、bool或者Tensor数据类型为 `number <https://www.mindspore.cn/docs/zh-CN/master/api_python/mindspore.html#mindspore.dtype>`_`bool_ <https://www.mindspore.cn/docs/zh-CN/master/api_python/mindspore.html#mindspore.dtype>`_
- **x1** (Union[Tensor, number.Number, bool]) - 第一个输入是number.Number、bool或者Tensor数据类型为 `number <https://www.mindspore.cn/docs/zh-CN/master/api_python/mindspore/mindspore.dtype.html#mindspore.dtype>`_
- **x2** (Union[Tensor, number.Number, bool]) - 当第一个输入是bool或数据类型为number或bool\_的Tensor时第二个输入是number.Number或bool。当第一个输入是Scalar时第二个输入必须是数据类型为number或bool\_的Tensor。
输出:

View File

@ -6,7 +6,7 @@ mindspore.ops.FloatStatus
确定元素是否包含非数字NaN、正无穷还是负无穷。0表示正常1表示溢出。
输入:
- **x** (Tensor) - 输入Tensor。数据类型必须为float16或float32:math:`(N,*)` ,其中 :math:`*` 表示任意数量的附加维度。
- **x** (Tensor) - 输入Tensor。数据类型必须为float16、float32或float64:math:`(N,*)` ,其中 :math:`*` 表示任意数量的附加维度。
输出:
Tensorshape为 :math:`(1,)` ,数据类型为 `mindspore.dtype.float32`

View File

@ -7,16 +7,16 @@ mindspore.ops.HistogramFixedWidth
参数:
- **nbins** (int) - 直方图的组数,类型为正整数。
- **dtype** (str, 可选) - 可选属性。数据类型必须为int32。默认值:"int32"。
- **dtype** (str, 可选) - 可选属性。数据类型必须为str。默认值:"int32"。
输入:
- **x** (Tensor) - HistogramFixedWidth的输入为一个Tensor。数据类型必须为int32、float32或float16。
- **range** (Tensor) - 数据类型与 `x` 相同shape为 :math:`(2,)` 。x <= range[0] 将映射到histogram[0]x >= range[1]将映射到histogram[-1]。
输出:
Tensor数据类型为int32。
1-D Tensor,其长度为 `nbins` 数据类型为int32。
异常:
- **TypeError** - 如果 `dtype` 不是str或 `nbins` 不是int。
- **ValueError** - 如果 `nbins` 小于1。
- **ValueError** - 如果 `dtype` 既不是 `int32` 也不是 `int64`
- **ValueError** - 如果 `dtype` 不是 "int32"

View File

@ -3,7 +3,7 @@ mindspore.ops.HistogramSummary
.. py:class:: mindspore.ops.HistogramSummary
将Tensor数据转换为直方图数据记录
通过HistogramSummary将Tensor数据输出到协议缓冲区
输入:
- **name** (str) - 输入变量的名称。

View File

@ -10,7 +10,7 @@ mindspore.ops.HookBackward
参数:
- **hook_fn** (Function) - Python函数。钩子函数。
- **cell_id** (str) - 用于标识钩子注册的函数是否实际注册在指定的cell对象上。例如'nn.Conv2d'是一个cell对象。cell_id的默认值为空字符串("")在这种情况下系统将自动注册cell_id的值。cell_id的值目前不支持自定义值
- **cell_id** (str,可选) - 用于标识钩子注册的函数是否实际注册在指定的cell对象上。例如:class:`mindspore.nn.Conv2d` 是一个cell对象。默认值"",此情况下系统将自动注册 `cell_id` 的值。 此参数目前不支持自定义
输入:
- **input** (Tensor) - 需要导出的变量的梯度。

View File

@ -18,4 +18,4 @@ mindspore.ops.InvertPermutation
异常:
- **TypeError** - 如果 `input_x` 既不是tuple也不是list。
- **TypeError** - 如果 `input_x` 的元素不是整数
- **TypeError** - 如果 `input_x` 的元素不是int

View File

@ -1,9 +1,9 @@
mindspore.ops.LSTM
===================
.. py:class:: mindspore.ops.LSTM(input_size, hidden_size, num_layers, has_bias, bidirectional, dropout)
.. py:class:: mindspore.ops.LSTM(input_size, hidden_size, num_layers, has_bias, bidirectional, dropout=0.0)
长短期记忆LSTM网络。
对输入执行长短期记忆LSTM网络。
有关详细信息,请参见 :class:`mindspore.nn.LSTM`
@ -13,7 +13,7 @@ mindspore.ops.LSTM
- **num_layers** (int) - LSTM的网络层数。
- **has_bias** (bool) - Cell是否有偏置 `b_ih``b_hh`
- **bidirectional** (bool) - 是否为双向LSTM。
- **dropout** (float) - 指的是除第一层外每层输入时的dropout概率。默认值0。dropout的范围为[0.0, 1.0]。
- **dropout** (float,可选) - 指的是除第一层外每层输入时的dropout概率。默认值0.0。dropout的范围为[0.0, 1.0]。
输入:
- **input** (Tensor) - shape为 :math:`(seq\_len, batch\_size, input\_size)`:math:`(batch\_size, seq\_len, input\_size)` 的Tensor。

View File

@ -3,6 +3,6 @@ mindspore.ops.Lerp
.. py:class:: mindspore.ops.Lerp
逐元素计算输入张量的最小值。
基于权重参数计算两个Tensor之间的线性插值。
有关更多详细信息,请参阅: :func:`mindspore.ops.lerp`

View File

@ -11,7 +11,7 @@ mindspore.ops.Multinomial
参数:
- **seed** (int) - 随机数种子必须是非负数。默认值0。
- **seed2** (int) - 二号随机数种子必须是非负数。默认值0。
- **dtype** (dtype) - 输出数据类型必须是int32或者int63默认类型int32。
- **dtype** (dtype) - 输出数据类型必须是int32或者int64默认类型int32。
输入:
- **x** (Tensor) - 包含累加概率和的输入Tensor必须是1维或2维。具有float16、float32或float64数据类型。CPU和GPU后端支持1维或者2维Ascend后端仅支持2维。
@ -22,6 +22,6 @@ mindspore.ops.Multinomial
异常:
- **TypeError** - 如果 `seed` 或者 `seed2` 不是int类型。
- **TypeError** - 如果 `x` 不是dtype为float16、float32或者float64的Tensor。
- **TypeError** - 如果 `x` 不是数据类型为float16、float32或者float64的Tensor。
- **TypeError** - 如果 `num_sample` 不是int类型。
- **TypeError** - 如果 `dtype` 不是int32或者int64类型。

View File

@ -13,3 +13,8 @@ mindspore.ops.count_nonzero
返回:
Tensor非零元素的数量。数据类型由 `dtype` 所指定。
异常:
- **TypeError** - `axis` 不是int、tuple或者list。
- **ValueError** - `axis` 不在[-x.ndim, x.ndim)范围内。

View File

@ -3,26 +3,26 @@ mindspore.ops.crop_and_resize
.. py:function:: mindspore.ops.crop_and_resize(image, boxes, box_indices, crop_size, method="bilinear", extrapolation_value=0.0)
对输入图像进行裁剪并调整其大小。
对输入图像Tensor进行裁剪并调整其大小。
.. note::
输出的shape依赖 `crop_size` `crop_size` 必须为常量。
当输出的shape依赖 `crop_size`的时候`crop_size` 必须为常量。
当前该算子的反向仅支持"bilinear"模式其他模式将会返回0。
参数:
- **image** (Tensor) - shape为 :math:`(batch, image_height, image_width, depth)` 的图像Tensor。数据类型int8, int16, int32, int64, float16, float32, float64, uint8, uint16。
- **image** (Tensor) - shape为 :math:`(batch, image\_height, image\_width, depth)` 的图像Tensor。数据类型int8, int16, int32, int64, float16, float32, float64, uint8, uint16。
- **boxes** (Tensor) - shape为 :math:`(num_boxes, 4)` 的2维Tensor。其中:math:`i` 行指定对第 :math:`\text{box_indices[i]}` 张图像裁剪时的归一化坐标 :math:`[y1, x1, y2, x2]`,那么通过归一化的 :math:`y` 坐标值可映射到的图像坐标为 :math:`y * (image\_height - 1)`,因此,归一化的图像高度 :math:`[0, 1]` 间隔映射到的图像高度间隔为 :math:`[0, image\_height - 1]`。我们也允许 :math:`y1 > y2`,这种情况下,就是对图像进行的上下翻转,宽度方向与此类似。同时,我们也允许归一化的坐标值超出 :math:`[0, 1]` 的区间,这种情况下,采用 :math:`\text{extrapolation_value}` 进行填充。数据类型float32。
- **box_indices** (Tensor) - shape为 :math:`(num_boxes)` 的1维Tensor其中每一个元素必须是 :math:`[0, batch)` 区间内的值。:math:`\test{box_indices[i]}` 指定 :math:`\test{boxes[i, :]}` 所指向的图像索引。数据类型int32。
- **crop_size** (Tuple[int]) - 2元组 :math:`(crop_height, crop_width)`该输入必须为常量并且均为正值。指定对裁剪出的图像进行调整时的输出大小纵横比可与原图不一致。数据类型int32。
- **method** (str) - 指定调整大小时的采样方法,取值为"bilinear"、 "nearest"或"bilinear_v2",其中,"bilinear"是标准的线性插值算法,而在某些情况下,"bilinear_v2"可能会得到更优的效果。默认值:"bilinear"。
- **extrapolation_value** (float) - 指定外插时的浮点值。默认值: 0.0。
- **box_indices** (Tensor) - shape为 :math:`(num\_boxes)` 的1维Tensor其中每一个元素必须是 :math:`[0, batch)` 区间内的值。:math:`\text{box_indices[i]}` 指定 :math:`\text{boxes[i, :]}` 所指向的图像索引。数据类型int32。
- **crop_size** (Tuple[int]) - 2元组(crop_height, crop_width)该输入必须为常量并且均为正值。指定对裁剪出的图像进行调整时的输出大小纵横比可与原图不一致。数据类型int32。
- **method** (str,可选) - 指定调整大小时的采样方法,取值为"bilinear"、 "nearest"或"bilinear_v2",其中,"bilinear"是标准的线性插值算法,而在某些情况下,"bilinear_v2"可能会得到更优的效果。默认值:"bilinear"。
- **extrapolation_value** (float,可选) - 指定外插时的浮点值。默认值: 0.0。
返回:
Tensorshape为 :math:`(num_boxes, crop_height, crop_width, depth)`数据类型float32 。
Tensorshape为(num_boxes, crop_height, crop_width, depth)数据类型float32 。
异常:
- **TypeError** - `image``boxes``box_indices` 不是Tensor。
- **TypeError** - `crop_size` 不是int32的2元组
- **TypeError** - `crop_size` 不是元素类型为int32的tuple`crop_size` 的长度不为2。
- **TypeError** - `boxes` 的数据类型不是float 或者,`box_indices` 的数据类型不是int32。
- **TypeError** - `method` 不是字符串。
- **TypeError** - `extrapolation_value` 不是浮点值。

View File

@ -3,7 +3,7 @@ mindspore.ops.cumsum
.. py:function:: mindspore.ops.cumsum(x, axis, dtype=None)
计算输入张量 `x` 沿维度 `axis` 的累积和。
计算输入Tensor `x` 沿轴 `axis` 的累积和。
.. math::
y_i = x_1 + x_2 + x_3 + ... + x_i
@ -13,11 +13,11 @@ mindspore.ops.cumsum
参数:
- **x** (Tensor) - 输入要累积和的Tensor。
- **axis** (int) - 累积和计算的维度
- **axis** (int) - 累积和计算的
- **dtype** (:class:`mindspore.dtype`, optional) - 输出数据类型。如果不为None则输入会转化为 `dtype`。这有利于防止数值溢出。如果为None则输出和输入的数据类型一致。默认值None。
返回:
Tensor和输入Tensor的形状相同。
Tensor和输入Tensor的shape相同。
异常:
- **TypeError** - 如果 `x` 不是Tensor。

View File

@ -3,7 +3,7 @@
.. py:function:: mindspore.ops.diagonal(input, offset=0, dim1=0, dim2=1)
返回 `input` 的部分视图,其相对于 `dim1``dim2` 的对角线元素作为维度附加在形状的末尾。
返回 `input` 特定的对角线视图。如果 `input` 为2-D返回偏移量为 `offset` 的对角线元素。如果 `input` 维度大于2则返回由 `dim1``dim2` 确定的2-D子数组的对角线视图。其相对于 `dim1``dim2` 的对角线元素作为维度附加在形状的末尾。
参数:
- **input** (Tensor) - 输入Tensor其维度至少为2。
@ -12,7 +12,7 @@
- **dim2** (int, 可选) - 二维子数组的第二轴对角线应该从这里开始。默认值1。
返回:
Tensor如果Tensor是二维则返回值是一维数组。
Tensor如果Tensor是二维则返回值是一维数组如果输入维度大于2则先移除维度 `dim1``dim2` 然后在末尾插入新的一维来对应对角元素
异常:
- **ValueError** - 输入Tensor的维度少于2。

View File

@ -19,12 +19,12 @@ mindspore.ops.div
- **rounding_mode** (str, 可选) - 应用于结果的舍入类型。三种类型被定义为None、"floor" 和 "trunc" 。默认值None。
- **None**: 默认行为。相当于Python中的 `true division` 或NumPy中的 `true_divide`
- **floor**: 将除法的结果向下舍入。相当于Python中的 `floor division` 或NumPy中的 `floor_divide`
- **trunc**: 将除法的结果舍入到零。相当于C型整数除法。
- **"floor"**: 将除法的结果向下舍入。相当于Python中的 `floor division` 或NumPy中的 `floor_divide`
- **"trunc"**: 将除法的结果舍入到零。相当于C型整数除法。
返回:
Tensor输出的shape与广播后的shape相同数据类型取两个输入中精度较高或数字较高的。
异常:
- **TypeError** - 如果 `input``other` 不是以下之一Tensor、Number、bool。
- **ValueError** - 如果 `rounding_mode` 不是以下之一None、floor、trunc。
- **ValueError** - 如果 `rounding_mode` 不是以下之一None、"floor""trunc"

View File

@ -3,11 +3,11 @@ mindspore.ops.dropout
.. py:function:: mindspore.ops.dropout(x, p=0.5, seed0=0, seed1=0)
dropout是一种正则化手段通过在训练中以 :math:`p` 的概率随机将神经元输出设置为0,起到减少神经元相关性的作用,避免过拟合。
在训练期间,以服从伯努利分布的概率 `p` 随机将输入Tensor的某些值归零,起到减少神经元相关性的作用,避免过拟合。
参数:
- **x** (Tensor) - dropout的输入任意维度的Tensor其数据类型为float16或float32。
- **p** (float可选) - 输入神经元保留概率数值范围在0到1之间。例如p=0.1删除10%的神经元。默认值0.5。
- **p** (float可选) - 输入神经元丢弃概率数值范围在0到1之间。例如p=0.1删除10%的神经元。默认值0.5。
- **seed0** (int可选) - 算子层的随机种子用于生成随机数。默认值0。
- **seed1** (int可选) - 全局的随机种子和算子层的随机种子共同决定最终生成的随机数。默认值0。

View File

@ -7,17 +7,6 @@ mindspore.ops.elu
对输入的每个元素计算ELU。该激活函数定义如下
.. math::
E_{i} =
\begin{cases}
x_i, &\text{if } x_i \geq 0; \cr
\alpha * (\exp(x_i) - 1), &\text{otherwise.}
\end{cases}
其中,:math:`x_i` 表示输入的元素,:math:`\alpha` 表示 `alpha` 参数。
ELU相关图参见 `ELU <https://en.wikipedia.org/wiki/Activation_function#/media/File:Activation_elu.svg>`_
.. math::
\text{ELU}(x)= \left\{
\begin{array}{align}
@ -25,9 +14,12 @@ mindspore.ops.elu
x & \text{if } x \gt 0\\
\end{array}\right.
其中,:math:`x` 表示输入的元素,:math:`\alpha` 表示 `alpha` 参数, `alpha` 决定ELU的平滑度。
ELU相关图参见 `ELU <https://en.wikipedia.org/wiki/Activation_function#/media/File:Activation_elu.svg>`_
参数:
- **input_x** (Tensor) - 用于计算ELU的任意维度的Tensor数据类型为float16或float32。
- **alpha** (float) - ELU的alpha值数据类型为浮点数。默认值1.0。。
- **input_x** (Tensor) - ELU的输入,为任意维度的Tensor数据类型为float16或float32。
- **alpha** (float) - ELU的alpha值数据类型为浮点数目前仅支持1.0。默认值1.0。
返回:
Tensor输出的shape、数据类型与 `input_x` 相同。

View File

@ -10,17 +10,17 @@ mindspore.ops.expand
参数:
- **input_x** (Tensor) - 输入Tensorshape为 :math:`(x_1, x_2, ..., x_R)`
- **size** (Tensor) - `input_x`shape大小
- **size** (Tensor) - `input_x` 扩展后的shape。
返回:
Tensor大小`size`
Tensorshape`size`
异常:
- **TypeError** - 如果 `input_x` 或者 `size` 不是Tensor。
- **TypeError** - 如果 `size` 的数据类型不是int16、int32或int64。
- **ValueError** - 如果 `size` 的长度小于 `input_x` shape的大小。
- **ValueError** - 如果 `size` 不是一个1D Tensor。
- **ValueError** - 如果 `size` 不等于 维度不为1的 `input_x` 的shape
- **ValueError** - 如果 `size` 小于0。
- **ValueError** - 如果 `size` 某维度的值不等于 `input_x` 对应维度的值,且 `input_x` 该维度不为1
- **ValueError** - 如果 `size` 小于0的值在最前面且对应` input_x` 不存在的维度上
- **ValueError** - 如果输出的元素数量超过1000000。

View File

@ -3,14 +3,14 @@ mindspore.ops.fills
.. py:function:: mindspore.ops.fills(x, value)
创建一个与输入Tensor具有相同shape和type的Tensor并用指定值填充。
创建一个与输入Tensor具有相同shape和dtype的Tensor并用指定值填充。
参数:
- **x** (Tensor) - 输入Tensor用来指定输出Tensor的shape和type。数据类型为int8int16int32float16float32。
- **x** (Tensor) - 输入Tensor用来指定输出Tensor的shape和dtype。数据类型为int8int16int32float16float32。
- **value** (Union[int, float, Tensor]) - 用来填充输出Tensor的值。数据类型为intfloat或0维Tensor。
返回:
Tensor与输入数据 `x` 具有相同的shape和type。
Tensor与输入数据 `x` 具有相同的shape和dtype。
异常:
- **TypeError** - `x` 不是Tensor。

View File

@ -15,7 +15,7 @@ mindspore.ops.floor_mod
其中 :math:`floor` 表示Floor算子有关更多详细信息请参阅 :class:`mindspore.ops.Floor` 算子。
.. warning::
- 输入数据不能等于0
- 输入 `y` 的元素不能等于0否则将返回当前数据类型的最大值
- 当输入元素数量超过2048时算子的精度不能保证千分之二的要求。
- 由于架构不同该算子在NPU和CPU上的计算结果可能不一致。
- 如果shape表示为 :math:`(D1、D2...、Dn)` ,那么 D1\*D2... \*DN<=1000000,n<=8.

View File

@ -30,4 +30,4 @@ mindspore.ops.gelu
Tensor具有与 `input_x` 相同的数据类型和shape。
异常:
- **TypeError** - `input_x` 的数据类型既不是float16也不是float32
- **TypeError** - `input_x` 的数据类型既不是float16、float32或者float64

View File

@ -8,16 +8,16 @@ mindspore.ops.glu
.. math::
{GLU}(a, b)= a \otimes \sigma(b)
其中,:math:`a` 表示输入input_x 拆分后 Tensor的前一半元素:math:`b` 表示输入拆分Tensor的另一半元素。
其中,:math:`a` 表示输入input_x 拆分后 Tensor的前一半元素:math:`b` 表示输入拆分Tensor的另一半元素。:math:`\sigma` 是sigmoid函数 :math:`*` 是Hadamard乘积。
请参考 `Language Modeling with Gated Convluational Networks <https://arxiv.org/abs/1612.08083>`_.
参数:
- **x** (Tensor) - :math:`(\ast_1, N, \ast_2)``x` 必须在 `axis` 轴能够被平均分成两份
- **axis** (int) - 指定分割轴。数据类型为整型,默认值:-1。
- **x** (Tensor) - 被分Tensor数据类型为number.Number, shape为 :math:`(\ast_1, N, \ast_2)` ,其中`*`为任意额外维度
- **axis** (int,可选) - 指定分割轴。数据类型为整型,默认值:-1。
返回:
Tensor数据类型与输入 `x` 相同shape等于 `x` 按照 `axis` 拆分后的一半。
Tensor数据类型与输入 `x` 相同shape:math:`(\ast_1, M, \ast_2)`,其中:math:`M=N/2`
异常:
- **TypeError** - `x` 数据类型不是Number。
- **TypeError** - `x` 数据类型不是number.Number。
- **TypeError** - `x` 不是Tensor。

View File

@ -12,9 +12,9 @@ mindspore.ops.laplace
参数:
- **shape** (tuple) - 指定生成随机Tensor的shape。格式为 :math:`(N,*)` ,其中 :math:`*` 表示任意数量的附加维度。
- **mean** (Tensor) - 均值μ分布参数指定峰的位置。数据类型为float32。
- **mean** (Tensor) - 均值μ分布参数,指定峰的位置。数据类型为float32。
- **lambda_param** (Tensor) - 用于控制此随机分布方差的参数。拉普拉斯分布的方差等于 `lambda_param` 平方的两倍。数据类型为float32。
- **seed** (int) - 随机种子用作生成随机数。默认值0。
- **seed** (int,可选) - 随机种子,用作生成随机数。默认值:None此时使用0作为seed
返回:
Tensor。输出shape应该是使用输入 `shape``mean``lambda_param` 广播后的shape。数据类型为float32。

View File

@ -14,7 +14,7 @@ mindspore.ops.lerp
参数:
- **start** (Tensor) - 进行线性插值的Tensor开始点其数据类型必须为float16或者float32。
- **end** (Tensor) - 进行线性插值的Tensor结束点其数据类型必须为float16或者float32
- **end** (Tensor) - 进行线性插值的Tensor结束点其数据类型必须`start` 一致
- **weight** (Union[float, Tensor]) - 线性插值公式的权重参数。为Scalar时其数据类型为float。为Tensor时其数据类型为float16或者float32。
返回:

View File

@ -5,7 +5,7 @@ mindspore.ops.less
逐元素计算 :math:`x < y` 返回为bool。
`x``y` 的输入遵循隐式类型转换规则使数据类型一致。输入必须是两个Tensor或一个Tensor和一个Scalar。当输入是两个Tensor时它们的数据类型不能同时bool它们的shape可以广播。当输入是一个Tensor和一个Scalar时Scalar只能是一个常量。
`x``y` 的输入遵循隐式类型转换规则使数据类型一致。输入必须是两个Tensor或一个Tensor和一个Scalar。当输入是两个Tensor时它们的数据类型不能同时bool它们的shape可以广播。当输入是一个Tensor和一个Scalar时Scalar只能是一个常量。
.. math::
out_{i} =\begin{cases}

View File

@ -19,7 +19,7 @@ mindspore.ops.less_equal
参数:
- **input** (Union[Tensor, number.Number, bool]) - 第一个输入是一个number.Number、bool值或数据类型为 `number <https://www.mindspore.cn/docs/zh-CN/master/api_python/mindspore/mindspore.dtype.html#mindspore.dtype>`_`bool_ <https://www.mindspore.cn/docs/zh-CN/master/api_python/mindspore/mindspore.dtype.html#mindspore.dtype>`_ 的Tensor。
- **other** (Union[Tensor, number.Number, bool]) - 第二个输入当第一个输入是Tensor时第二个输入应该是一个number.Number或bool值或数据类型为number或bool_的Tensor。当第一个输入是Scalar时第二个输>入必须是数据类型为number或bool_的Tensor。
- **other** (Union[Tensor, number.Number, bool]) - 第二个输入当第一个输入是Tensor时第二个输入应该是一个number.Number或bool值或数据类型为number或bool_的Tensor。当第一个输入是Scalar时第二个输入必须是数据类型为number或bool_的Tensor。
返回:
Tensorshape与广播后的shape相同数据类型为bool。

View File

@ -3,18 +3,18 @@ mindspore.ops.log_matrix_determinant
.. py:function:: mindspore.ops.log_matrix_determinant(x)
计算一个或多个平方矩阵行列式绝对值的对数的符号和绝对值的对数
对一个或多个方阵行列式的绝对值取对数,返回其符号和值
参数:
- **x** (Tensor) - 输入Tensorshape为 :math:`[..., M, M]` 。矩阵必须至少有两个维度最后两个维度尺寸必须相同。支持的数据类型为float32、float64、complex64或complex128。
返回:
Tensor行列式的绝对值的对数的符号shape为 `x_shape[:-2]` ,数据类型与 `x` 相同。
Tensor行列式的绝对值的对数的符号shape为 `x.shape[:-2]` ,数据类型与 `x` 相同。
Tensor行列式的绝对值的对数shape为 `x_shape[:-2]` ,数据类型与 `x` 相同。
Tensor行列式的绝对值的对数shape为 `x.shape[:-2]` ,数据类型与 `x` 相同。
异常:
- **TypeError** - `x` 不为 Tensor。
- **TypeError** - `x` 的数据类型不为以下类型: mstype.float32、 mstype.float64、 mstype.complex64 和 mstype.complex128。
- **TypeError** - `x` 的数据类型不为以下类型float32、 float64、 complex64 和 complex128。
- **ValueError** - `x` 的最后两个维度大小不同。
- **ValueError** - `x` 的维数小于2。

View File

@ -3,8 +3,8 @@ mindspore.ops.logit
.. py:function:: mindspore.ops.logit(x, eps=None)
逐元素计算张量的logit值。当 eps 不是 None 时, `x` 中的元素被截断到范围[eps, 1-eps]内。
当 eps 为 None 时,输入 `x` 不进行数值截断。
逐元素计算Tensor的logit值。当 `eps` 不是 None 时, `x` 中的元素被截断到范围[eps, 1-eps]内。
`eps` 为 None 时,输入 `x` 不进行数值截断。
.. math::
\begin{align}
@ -18,7 +18,7 @@ mindspore.ops.logit
\end{align}
参数:
- **x** (Tensor) - 张量输入。
- **x** (Tensor) - Tensor输入。
- **eps** (float, 可选) - epsilon值。输入的数值界限被定义[eps, 1-eps]。默认值None。
返回:

View File

@ -9,10 +9,10 @@ mindspore.ops.matrix_determinant
- **x** (Tensor) - 输入Tensor shape 为 :math:`[..., M, M]` 。矩阵必须至少有两个维度最后两个维度尺寸必须相同。支持的数据类型为float32、float64、complex64或complex128。
返回:
Tensor形状为 `x_shape[:-2]` ,数据类型与 `x` 相同。
Tensor形状为 `x.shape[:-2]` ,数据类型与 `x` 相同。
异常:
- **TypeError** - `x` 不为 Tensor。
- **TypeError** - `x` 的数据类型不为以下类型: mstype.float32、 mstype.float64、 mstype.complex64 和 mstype.complex128。
- **TypeError** - `x` 的数据类型不为以下类型float32、float64、complex64 和 complex128。
- **ValueError** - `x` 的最后两个维度大小不同。
- **ValueError** - `x` 的维数小于2。

View File

@ -3,7 +3,7 @@ mindspore.ops.mean
.. py:function:: mindspore.ops.mean(x, axis=(), keep_dims=False)
默认情况下,使用指定维度的平均值代替该维度的其他元素,以移除该维度。也可仅缩小该维度大小至1。 `keep_dims` 控制输出和输入的维度是否相同。
默认情况下,移除输入所有维度,返回 `x` 中所有元素的平均值。也可仅缩小指定维度 `axis` 大小至1。 `keep_dims` 控制输出和输入的维度是否相同。
参数:
- **x** (Tensor[Number]) - 输入Tensor其数据类型为数值型。shape :math:`(N, *)` ,其中 :math:`*` 表示任意数量的附加维度。秩应小于8。
@ -19,6 +19,6 @@ mindspore.ops.mean
异常:
- **TypeError** - `x` 不是Tensor。
- **TypeError** - `axis` 不是以下数据类型之一int、Tuple或List。
- **TypeError** - `axis` 不是以下数据类型之一int、tuple或list。
- **TypeError** - `keep_dims` 不是bool类型。
- **ValueError** - `axis` 超出范围。

View File

@ -11,7 +11,7 @@ mindspore.ops.median
参数:
- **x** (Tensor) - median的输入任意维度的Tensor。数据类型支持int16、int32、int64、float32或float64。
- **global_median** (bool) - 表示是否对x的全部元素取中值。默认值False。
- **axis** (int) - 指定计算维度。默认值:(0), 取值范围为[-dims, dims - 1]`dims` 表示 `x` 的维度长度
- **axis** (int,可选) - 指定计算维度。默认值0。取值范围为[-dims, dims - 1]`dims` 表示 `x` 的维度长度
- **keep_dims** (bool) - 表示是否减少维度如果为True输出将与输入保持相同的维度如果为False输出将减少维度。默认值False。
返回:

View File

@ -11,7 +11,7 @@ mindspore.ops.multinomial
参数:
- **inputs** (Tensor) - 输入的概率值Tensor必须是1维或2维数据类型为float32。
- **num_sample** (int) - 采样的次数。
- **replacement** (bool, 可选) - 是否是可放回的采样默认True。
- **replacement** (bool, 可选) - 是否是可放回的采样,默认True。
- **seed** (int, 可选) - 随机数种子,用于生成随机数(伪随机数)必须是非负数。默认值None。
返回:

View File

@ -61,6 +61,10 @@ def count_nonzero(x, axis=(), keep_dims=False, dtype=mstype.int32):
Returns:
Tensor, number of nonzero element. The data type is `dtype`.
Raises:
TypeError: If axis is not int or tuple.
ValueError: If axis is not in range [-x.ndim, x.ndim).
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``

View File

@ -104,7 +104,7 @@ def laplace(shape, mean, lambda_param, seed=None):
With float32 data type.
lambda_param (Tensor): The parameter used for controlling the variance of this random distribution. The
variance of Laplace distribution is equal to twice the square of lambda_param. With float32 data type.
seed (int): Seed is used as entropy source for Random number engines generating pseudo-random numbers.
seed (int, optional): Seed is used as entropy source for Random number engines generating pseudo-random numbers.
Default: None, which will be treated as 0.
Returns:
@ -345,7 +345,7 @@ def multinomial(inputs, num_sample, replacement=True, seed=None):
inputs (Tensor): The input tensor containing probabilities, must be 1 or 2 dimensions, with
float32 data type.
num_sample (int): Number of samples to draw.
replacement (bool, optional): Whether to draw with replacement or not, default True.
replacement (bool, optional): Whether to draw with replacement or not, default: True.
seed (int, optional): Seed is used as entropy source for the random number engines to generate
pseudo-random numbers, must be non-negative. Default: None.

View File

@ -4586,19 +4586,20 @@ def expand(input_x, size):
Args:
input_x (Tensor): The shape of tensor is (x_1, x_2, ..., x_R).
size (Tensor): The new shape of `input_x`.
size (Tensor): The expanded shape of `input_x`.
Returns:
y (Tensor) - Tensor after expansion.
y (Tensor) - Tensor after expansion whose shape is `size`.
Raises:
TypeError: If any input is not Tensor.
TypeError: If `input_x` or `size` is not Tensor.
TypeError: If the type of `size` is not one of the following dtype: int16, int32, int64.
ValueError: If `size` is not a 1-D tensor.
ValueError: If the size of `size` is less than the size of `input_x.shape`.
ValueError: If `size` is not a 1-D tensor.
ValueError: If the expanded `size` is not equal to the existing shape of `input_x` at a dimension
that is not 1.
ValueError: If the expanded `size` < 0 and it is in a leading, non-existing dimension.
ValueError: If the expanded `size` < 0 and it is in a leading position, corresponding to
a non-existing dimension in `input_x`.
ValueError: If the number of elements of output is more than 1000000.
Supported Platforms:
@ -4750,21 +4751,30 @@ def _check_diagonal_axes(dim1, dim2, x_ndim):
def diagonal(input, offset=0, dim1=0, dim2=1):
"""
Returns a partial view of input with the its diagonal elements with respect to `dim1` and `dim2`
appended as a dimension at the end of the shape.
Returns specified diagonals of `input`.
If `input` is 2-D, returns the diagonal of `input` with the given offset.
If `a` has more than two
dimensions, then the axes specified by `dim1` and `dim2` are used to determine
the 2-D sub-array whose diagonal is returned. The shape of the resulting
array can be determined by removing `dim1` and `dim2` and appending an index
to the right equal to the size of the resulting diagonals.
Args:
input (Tensor): The input tensor. Must be at least 2-dimensional.
a (Tensor): Array from which the diagonals are taken.
offset (int, optional): Offset of the diagonal from the main diagonal.
Can be positive or negative. Default: 0.
dim1 (int, optional): Dimension to be used as the first dim of the 2-D
sub-arrays from which the diagonals should be taken. Default: 0.
dim2 (int, optional): Dimension to be used as the second dim of the 2-D
sub-arrays from which the diagonals should be taken. Default: 1.
Can be positive or negative. Defaults: 0.
dim1 (int, optional): Axis to be used as the first axis of the 2-D
sub-arrays from which the diagonals should be taken. Defaults to
first axis (0).
dim2 (int, optional): Axis to be used as the second axis of the 2-D
sub-arrays from which the diagonals should be taken. Defaults to
second axis (1).
Returns:
Tensor, a partial view of input with the its diagonal elements with respect to `dim1` and `dim2`
appended as a dimension at the end of the shape.
Tensor, if `input` is 2-D, then `input` 1-D array containing the diagonal. If
``input.ndim > 2``, then the dimensions specified by `dim1` and `dim2` are removed,
and a new axis inserted at the end corresponding to the diagonal.
Raises:
ValueError: if the input tensor has less than two dimensions.

View File

@ -140,14 +140,14 @@ def check_valid(bboxes, img_metas):
def crop_and_resize(image, boxes, box_indices, crop_size, method="bilinear", extrapolation_value=0.0):
"""
Extracts crops from the input image tensor and resizes them.
Extracts crops from the input image Tensor and resizes them.
Note:
In case that the output shape depends on crop_size, the crop_size must be constant.
For now, the backward of the operator only support bilinear method, for other methods, will return 0.
Args:
image (Tensor): The input image must be a 4-D tensor of shape [batch, image_height, image_width, depth].
image (Tensor): The input image must be a 4-D tensor of shape (batch, image_height, image_width, depth).
Types allowed: int8, int16, int32, int64, float16, float32, float64, uint8, uint16.
boxes (Tensor): A 2-D tensor of shape [num_boxes, 4].
The i-th row of the tensor specifies the coordinates of a box in the box_ind[i] image
@ -162,10 +162,10 @@ def crop_and_resize(image, boxes, box_indices, crop_size, method="bilinear", ext
crop_size (Tuple[int]): A tuple of two int32 elements: (crop_height, crop_width).
Only constant value is allowed. All cropped image patches are resized to this size.
The aspect ratio of the image content is not preserved. Both crop_height and crop_width need to be positive.
method (str): An optional string that specifies the sampling method for resizing.
method (str, optional): An optional string that specifies the sampling method for resizing.
It can be "bilinear", "nearest" or "bilinear_v2". The option "bilinear" stands for standard bilinear
interpolation algorithm, while "bilinear_v2" may result in better result in some cases. Default: "bilinear"
extrapolation_value (float): An optional float value used extrapolation, if applicable. Default: 0.0.
extrapolation_value (float, optional): An optional float value used extrapolation, if applicable. Default: 0.0.
Returns:
A 4-D tensor of shape [num_boxes, crop_height, crop_width, depth] with type(float32).

View File

@ -627,10 +627,10 @@ def div(input, other, rounding_mode=None):
- None: Default behavior. Equivalent to true division in Python or `true_divide` in NumPy.
- floor: Rounds the results of the division down. Equivalent to floor division in Python
- "floor": Rounds the results of the division down. Equivalent to floor division in Python
or `floor_divide` in NumPy.
- trunc: Rounds the results of the division towards zero. Equivalent to C-style integer division.
- "trunc": Rounds the results of the division towards zero. Equivalent to C-style integer division.
Default: None.
Returns:
@ -639,7 +639,7 @@ def div(input, other, rounding_mode=None):
Raises:
TypeError: If `input` and `other` is not one of the following: Tensor, Number, bool.
ValueError: If `rounding_mode` value is not None, `floor` or `trunc`.
ValueError: If `rounding_mode` value is not None, "floor" or "trunc".
Supported Platforms:
``Ascend`` ``CPU`` ``GPU``
@ -680,7 +680,8 @@ def floor_div(x, y):
out_{i} = \\text{floor}( \\frac{x_i}{y_i})
where the :math:`floor` indicates the Floor operator, for more details, please refer to the Floor operator.
where the :math:`floor` indicates the Floor operator, for more details,
please refer to the :class:`mindspore.ops.Floor` operator.
Args:
x (Union[Tensor, Number, bool]): The first input is a number or
@ -774,10 +775,11 @@ def floor_mod(x, y):
out_{i} =\text{floor}(x_{i} // y_{i})
where the :math:`floor` indicates the Floor operator, for more details, please refer to the Floor operator.
where the :math:`floor` indicates the Floor operator, for more details,
please refer to the :class:`mindspore.ops.Floor` operator.
.. warning::
- The input data does not support 0.
- Data of input `y` should not be 0, or the maximum value of its dtype will be returned.
- When the elements of input exceeds 2048 , the accuracy of operator cannot guarantee the requirement of
double thousandths in the mini form.
- Due to different architectures, the calculation results of this operator on NPU and CPU may be inconsistent.
@ -1258,7 +1260,8 @@ def cos(x):
out_i = cos(x_i)
.. warning::
If use Float64, there may be a problem of missing precision.
Supported dtypes are float16 and float32, and using float64 may
cause a problem of missing precision.
Args:
x (Tensor): The shape of tensor is
@ -2178,11 +2181,12 @@ def matrix_determinant(x):
Computes the determinant of one or more square matrices.
Args:
x (Tensor): A matrix to be calculated. The matrix must be at least two dimensions, and the last two
x (Tensor): A matrix to be calculated, its shape should be :math:`[..., M, M]` who must
have at least two dimensions, and the last two
dimensions must be the same size. Data type must be float32, float64, complex64 or complex128.
Returns:
Tensor, The shape is :math:`x\_shape[:-2]`, the dtype is same as `x`.
Tensor. The shape is `x.shape[:-2]`, and the dtype is same as `x`.
Raises:
TypeError: If `x` is not a Tensor.
@ -2242,14 +2246,13 @@ def log_matrix_determinant(x):
Computes the sign and the log of the absolute value of the determinant of one or more square matrices.
Args:
x (Tensor): A matrix to be calculated. The matrix must be at least two dimensions, and the last two
x (Tensor): A matrix to be calculated, its shape is :math:`[..., M, M]`.
The matrix must be at least two dimensions, and the last two
dimensions must be the same size. Data type must be float32, float64, complex64 or complex128.
Returns:
Tensor, The signs of the log determinants. The shape is :math:`x\_shape[:-2]`, the dtype is same as `x`.
Tensor, The absolute values of the log determinants. The shape is :math:`x\_shape[:-2]`,
Tensor. The signs of the log determinants. The shape is `x.shape[:-2]`, and the dtype is same as `x`.
Tensor. The absolute values of the log determinants. The shape is :math:`x.shape[:-2]`, and
the dtype is same as `x`.
Raises:
@ -3141,13 +3144,13 @@ def median(x, global_median=False, axis=0, keep_dims=False):
Computes the median of input tensor.
.. warning::
When attr `global_median` is True, the second output Tensor value is meaningless.
When attr `global_median` is True, the second output Tensor `value` is meaningless.
Args:
x (Tensor): The first input is a tensor whose data type is number.
x (Tensor): A Tensor of any dimension whose data type is int16, int32, int64, float32 or float64.
global_median (bool): Whether the output tensor is the global median of all input tensor elements or not.
Default: False.
axis (int): The dimension need to reduce. Default: 0.
axis (int, optional): The dimension need to reduce. Default: 0.
keep_dims (bool): Whether the output tensor need to retain `axis` dimension or not. Default: False.
Returns:
@ -3855,7 +3858,7 @@ def lerp(start, end, weight):
Args:
start (Tensor): The tensor with the starting points. Data type must be float16 or float32.
end (Tensor): The tensor with the ending points. Data type must be float16 or float32.
end (Tensor): The tensor with the ending points. Data type must be the same as `start`.
weight (Union[float, Tensor]): The weight for the interpolation formula. Must be a float
or a scalar tensor with float16 or float32 data type.
@ -4281,7 +4284,7 @@ def cummax(x, axis):
def cumsum(x, axis, dtype=None):
"""
Computes the cumulative sum of input Tensor along axis.
Computes the cumulative sum of input Tensor along `axis`.
.. math::
@ -4769,9 +4772,9 @@ def amax(x, axis=(), keep_dims=False):
def mean(x, axis=(), keep_dims=False):
r"""
Reduces a dimension of a tensor by averaging all elements in the dimension, by default. And also can reduce
a dimension of `x` along the axis. Determine whether the dimensions of the output and input are the same by
controlling `keep_dims`.
Reduces all dimension of a tensor by averaging all elements in the dimension, by default.
And reduce a dimension of `x` along the specified `axis`. `keep_dims`
determines whether the dimensions of the output and input are the same.
Args:
x (Tensor[Number]): The input tensor. The dtype of the tensor to be reduced is number.
@ -6546,10 +6549,10 @@ def less_equal(input, other):
.. note::
- Inputs of `input` and `other` comply with the implicit type conversion rules to make the data types
consistent.
consistent.
- The inputs must be two tensors or one tensor and one scalar.
- When the inputs are two tensors, dtypes of them cannot be both bool , and the shapes of them
can be broadcast.
- When the inputs are two tensors, dtypes of them cannot be both bool, and the shapes of them
can be broadcast.
- When the inputs are one tensor and one scalar, the scalar could only be a constant.
Args:

View File

@ -973,7 +973,8 @@ def binary_cross_entropy_with_logits(logits, label, weight, pos_weight, reductio
def dropout(x, p=0.5, seed0=0, seed1=0):
"""
During training, randomly zeroes some of the elements of the input tensor
with probability `p` from a Bernoulli distribution.
with probability `p` from a Bernoulli distribution. It plays the role of
reducing neuron correlation and avoid overfitting.
Args:
x (Tensor): The input of Dropout, a Tensor of any shape with data type of float16 or float32.
@ -3773,14 +3774,15 @@ def glu(x, axis=-1):
See `Language Modeling with Gated Convluational Networks <https://arxiv.org/abs/1612.08083>`_.
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.
x (Tensor): Tensor to be splited. Its dtype is number.Number, and shape is :math:`(\ast_1, N, \ast_2)`
where `*` means, any number of additional dimensions.
axis (int, optional): the dimension on which to split the input. It must be int. Default: -1.
Returns:
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.
TypeError: If dtype of `x` is not number.Number.
TypeError: If `x` is not a Tensor.
Supported Platforms:
@ -3872,8 +3874,6 @@ def multi_margin_loss(inputs, target, p=1, margin=1, weight=None, reduction='mea
def multi_label_margin_loss(inputs, target, reduction='mean'):
r"""
MultilabelMarginLoss operation.
Creates a criterion that optimizes a multi-class multi-classification
hinge loss (margin-based loss) between input :math:`x` (a 2D mini-batch `Tensor`)
and output :math:`y` (which is a 2D `Tensor` of target class indices).
@ -3894,7 +3894,7 @@ def multi_label_margin_loss(inputs, target, reduction='mean'):
Args:
inputs (Tensor): Predict data. Tensor of shape :math:`(C)` or :math:`(N, C)`, where :math:`N`
is the batch size and :math:`C` is the number of classes. Data type must be float16 or float32.
target (Tensor): Ground truth data, with the same shape as `x`, data type must be int32 and
target (Tensor): Ground truth data, with the same shape as `inputs`, data type must be int32 and
label targets padded by -1.
reduction (str, optional): Apply specific reduction method to the output: 'none', 'mean',
'sum'. Default: 'mean'.
@ -3948,7 +3948,8 @@ def elu(input_x, alpha=1.0):
\alpha(e^{x} - 1) & \text{if } x \le 0\\
x & \text{if } x \gt 0\\
\end{array}\right.
Where :math:`x` is the element of input Tensor, :math:`\alpha` is param `alpha`,
it determines the smoothness of ELU.
The picture about ELU looks like this `ELU <https://en.wikipedia.org/wiki/
Activation_function#/media/File:Activation_elu.svg>`_ .

View File

@ -629,16 +629,16 @@ def csr_softmax(logits: CSRTensor, dtype: mstype):
Calculates the softmax of a CSRTensorMatrix.
Args:
logits (CSRTensor): Sparse CSR Tensor.
dtype (dtype): Data type.
logits (CSRTensor): Input sparse CSRTensor.
dtype (dtype): Input data type.
Returns:
CSRTensor, a csr_tensor containing
- **indptr** - indicates the start and end point for `values` in each row.
- **indices** - the column positions of all non-zero values of the input.
- **values** - the non-zero values of the dense tensor.
- **shape** - the shape of the csr_tensor.
- **indptr** - Indicates the start and end point for non-zero values in each row.
- **indices** - The column positions of all non-zero values of the input.
- **values** - The non-zero values of the dense tensor.
- **shape** - The shape of the csr_tensor.
Supported Platforms:
``GPU`` ``CPU``
@ -682,18 +682,18 @@ def csr_add(a: CSRTensor, b: CSRTensor, alpha: Tensor, beta: Tensor) -> CSRTenso
operator may return an error of fail execute.
Args:
a (CSRTensor): Sparse CSR Tensor.
b (CSRTensor): Sparse CSR Tensor.
a (CSRTensor): Input sparse CSRTensor.
b (CSRTensor): Input sparse CSRTensor.
alpha(Tensor): Dense Tensor, its shape must be able to broadcast to a.
beta(Tensor): Dense Tensor, its shape must be able to broadcast to b.
Returns:
CSRTensor, a csr_tensor containing the following parts.
- **indptr** - indicates the start and end point for `values` in each row.
- **indices** - the column positions of all non-zero values of the input.
- **values** - the non-zero values of the dense tensor.
- **shape** - the shape of the csr_tensor.
- **indptr** - Indicates the start and end point for non-zero values in each row.
- **indices** - The column positions of all non-zero values of the input.
- **values** - The non-zero values of the dense tensor.
- **shape** - The shape of the csr_tensor.
Supported Platforms:
``GPU`` ``CPU``

View File

@ -5809,9 +5809,9 @@ class EditDistance(Primitive):
i and j here in may be considered as lengths of a and b.
.. warning::
- Unorded `truth_indices` or `hypothesis_indices` might lead to expected result, so it is suggested to
make sure `truth_indices` and `hypothesis_indices` are both in ascending order before
calling this API.
Unorded `truth_indices` or `hypothesis_indices` might lead to expected result, so it is suggested to
make sure `truth_indices` and `hypothesis_indices` are both in ascending order before
calling this API.
Args:
normalize (bool): If true, edit distances are normalized by length of truth. Default: True.
@ -6885,8 +6885,8 @@ class ExtractVolumePatches(Primitive):
Outputs:
Tensor, has the same type as input.
If padding is VALID, the shape is :math:`(x_n, k_d * k_h * k_w * x_c, 1 + (x_d - k_d) / s_d,
1 + (x_h - k_h) / s_h, 1 + (x_w - k_w) / s_w)`; if padding is SAME, the shape is :math:`(
If padding is "VALID", the shape is :math:`(x_n, k_d * k_h * k_w * x_c, 1 + (x_d - k_d) / s_d,
1 + (x_h - k_h) / s_h, 1 + (x_w - k_w) / s_w)`; if padding is "SAME", the shape is :math:`(
x_n, k_d * k_h * k_w * x_c, (x_d + s_d - 1) / s_d, (x_h + s_h - 1) / s_h, (x_w + s_w - 1) / s_w)`.
Raises:

View File

@ -349,11 +349,11 @@ class HookBackward(PrimitiveWithInfer):
Args:
hook_fn (Function): Python function. hook function.
cell_id (str): Used to identify whether the function registered by the hook is actually registered on
cell_id (str, optional): Used to identify whether the function registered by the hook is actually registered on
the specified cell object. For example, 'nn.Conv2d' is a cell object.
The default value of cell_id is empty string(""), in this case, the system will automatically
register a value of cell_id.
The value of cell_id currently does not support custom values.
The default value of `cell_id` is empty string(""), in this case, the system will automatically
register a value of `cell_id`.
The value of `cell_id` currently does not support custom values.
Inputs:
- **input** (Tensor) - The variable to hook.

View File

@ -289,10 +289,10 @@ class CropAndResize(Primitive):
the image coordinate at y * (image_height - 1), so as the [0, 1] interval of normalized image height is
mapped to [0, image_height - 1] in image height coordinates. We do allow y1 > y2, in which case the sampled
crop is an up-down flipped version of the original image. The width dimension is treated similarly.
Normalized coordinates outside the [0, 1] range are allowed, in which case we use extrapolation_value to
Normalized coordinates outside the [0, 1] range are allowed, in which case we use `extrapolation_value` to
extrapolate the input image values. Types allowed: float32.
- **box_index** (Tensor) - A 1-D tensor of shape [num_boxes] with int32 values in [0, batch).
The value of box_ind[i] specifies the image that the i-th box refers to. Types allowed: int32.
The value of `box_index`[i] specifies the image that the i-th box refers to. Types allowed: int32.
- **crop_size** (Tuple[int]) - A tuple of two int32 elements: (crop_height, crop_width).
Only constant value is allowed. All cropped image patches are resized to this size.
The aspect ratio of the image content is not preserved. Both crop_height and crop_width need to be positive.

View File

@ -2387,7 +2387,8 @@ class ReduceStd(Primitive):
class Einsum(Primitive):
"""
This operator uses equation to represent a tuple of tensors operations.
Sums the product of the elements of the input Tensor along
dimensions specified notation based on the Einstein summation convention(Einsum).
You can use this operator to perform diagonal/reducesum/transpose/matmul/mul/inner product operations, etc.
The inputs must be a tuple of tensors.
@ -2627,8 +2628,8 @@ class HistogramFixedWidth(PrimitiveWithInfer):
width and determined by the inputs `range` and the arguments `nbins`.
Args:
dtype (str, optional): An optional attribute. The dtype must be "int32". Default: "int32".
nbins (int): The number of histogram bins, the type is a positive integer.
dtype (str, optional): An optional attribute. The dtype must be str. Default: "int32".
Inputs:
- **x** (Tensor) - Numeric Tensor. Must be one of the following types: int32, float32, float16.
@ -2636,12 +2637,12 @@ class HistogramFixedWidth(PrimitiveWithInfer):
x <= range[0] will be mapped to histogram[0], x >= range[1] will be mapped to histogram[-1].
Outputs:
Tensor, the type is int32.
1-D Tensor, whose length is the type is `nbins` with dtype of int32.
Raises:
TypeError: If `dtype` is not a str or `nbins` is not an int.
ValueError: If `nbins` is less than 1.
ValueError: If `dtype` is neither 'int32' nor 'int64'.
ValueError: If `dtype` is not 'int32'.
Supported Platforms:
``Ascend`` ``GPU``
@ -3040,7 +3041,7 @@ class DivNoNan(Primitive):
- **x1** (Union[Tensor, number.Number, bool]) - The first input is a number.Number or
a bool or a tensor whose data type is
`number <https://www.mindspore.cn/docs/en/master/api_python/mindspore.html#mindspore.dtype>`_ or
`bool_ <https://www.mindspore.cn/docs/en/master/api_python/mindspore.html#mindspore.dtype>`_.
`bool_ <https://www.mindspore.cn/docs/zh-CN/master/api_python/mindspore/mindspore.dtype.html#mindspore.dtype>`_.
- **x2** (Union[Tensor, number.Number, bool]) - The second input is a number.Number or
a bool when the first input is a bool or a tensor whose data type is number or bool\_.
When the first input is Scalar, the second input must be a Tensor whose data type is number or bool\_.
@ -3882,7 +3883,7 @@ class GreaterEqual(PrimitiveWithCheck):
class Lerp(Primitive):
"""
Computes the minimum of input tensors element-wise.
Calculate the linear interpolation between two tensors based on the weight parameter.
Refer to :func:`mindspore.ops.lerp` for more detail.
@ -4196,7 +4197,7 @@ class FloatStatus(Primitive):
Determines if the elements contain Not a Number(NaN), infinite or negative infinite. 0 for normal, 1 for overflow.
Inputs:
- **x** (Tensor) - The input tensor. The data type must be float16 or float32.
- **x** (Tensor) - The input tensor. The data type must be float16, float32 or float64.
:math:`(N,*)` where :math:`*` means, any number of additional dimensions.
Outputs:

View File

@ -4169,7 +4169,7 @@ class LSTM(PrimitiveWithInfer):
num_layers (int): Number of layers of stacked LSTM.
has_bias (bool): Whether the cell has bias `b_ih` and `b_hh`.
bidirectional (bool): Specifies whether it is a bidirectional LSTM.
dropout (float): If not 0, append `Dropout` layer on the outputs of each
dropout (float, optional): If not 0, append `Dropout` layer on the outputs of each
LSTM layer except the last layer. The range of dropout is [0.0, 1.0].
Inputs:
@ -7021,12 +7021,20 @@ class SparseApplyFtrlV2(PrimitiveWithInfer):
class Dropout(PrimitiveWithCheck):
"""
During training, randomly zeroes some of the elements of the input tensor
with probability 1-`keep_prob` from a Bernoulli distribution.
with probability 1-`keep_prob` from a Bernoulli distribution. It plays the
role of reducing neuron correlation and avoid overfitting.
Refer to :func:`mindspore.ops.dropout` for more detail.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> dropout = ops.Dropout3D(keep_prob=0.5)
>>> x = Tensor(np.ones([1, 2, 3, 4, 5]), mindspore.float32)
>>> output, mask = dropout(x)
>>> print(output.shape)
(1, 2, 3, 4, 5)
"""
@prim_attr_register