diff --git a/docs/api/api_python/ops/mindspore.ops.CropAndResize.rst b/docs/api/api_python/ops/mindspore.ops.CropAndResize.rst index 1f31365d6bc..807e1417034 100644 --- a/docs/api/api_python/ops/mindspore.ops.CropAndResize.rst +++ b/docs/api/api_python/ops/mindspore.ops.CropAndResize.rst @@ -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元素元素组成的tuple:(crop_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` 不是浮点值。 diff --git a/docs/api/api_python/ops/mindspore.ops.DivNoNan.rst b/docs/api/api_python/ops/mindspore.ops.DivNoNan.rst index 85e7f37415e..833cfc3780e 100644 --- a/docs/api/api_python/ops/mindspore.ops.DivNoNan.rst +++ b/docs/api/api_python/ops/mindspore.ops.DivNoNan.rst @@ -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 `_ 或 `bool_ `_ 。 + - **x1** (Union[Tensor, number.Number, bool]) - 第一个输入是number.Number、bool或者Tensor,数据类型为 `number `_ 。 - **x2** (Union[Tensor, number.Number, bool]) - 当第一个输入是bool或数据类型为number或bool\_的Tensor时,第二个输入是number.Number或bool。当第一个输入是Scalar时,第二个输入必须是数据类型为number或bool\_的Tensor。 输出: diff --git a/docs/api/api_python/ops/mindspore.ops.FloatStatus.rst b/docs/api/api_python/ops/mindspore.ops.FloatStatus.rst index 4d988840843..55e7f4af923 100644 --- a/docs/api/api_python/ops/mindspore.ops.FloatStatus.rst +++ b/docs/api/api_python/ops/mindspore.ops.FloatStatus.rst @@ -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:`*` 表示任意数量的附加维度。 输出: Tensor,shape为 :math:`(1,)` ,数据类型为 `mindspore.dtype.float32` 。 diff --git a/docs/api/api_python/ops/mindspore.ops.HistogramFixedWidth.rst b/docs/api/api_python/ops/mindspore.ops.HistogramFixedWidth.rst index 7c294d88123..43701957f58 100644 --- a/docs/api/api_python/ops/mindspore.ops.HistogramFixedWidth.rst +++ b/docs/api/api_python/ops/mindspore.ops.HistogramFixedWidth.rst @@ -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"。 diff --git a/docs/api/api_python/ops/mindspore.ops.HistogramSummary.rst b/docs/api/api_python/ops/mindspore.ops.HistogramSummary.rst index 9ac173ee9e8..ccf164d7290 100644 --- a/docs/api/api_python/ops/mindspore.ops.HistogramSummary.rst +++ b/docs/api/api_python/ops/mindspore.ops.HistogramSummary.rst @@ -3,7 +3,7 @@ mindspore.ops.HistogramSummary .. py:class:: mindspore.ops.HistogramSummary - 将Tensor数据转换为直方图数据记录。 + 通过HistogramSummary将Tensor数据输出到协议缓冲区。 输入: - **name** (str) - 输入变量的名称。 diff --git a/docs/api/api_python/ops/mindspore.ops.HookBackward.rst b/docs/api/api_python/ops/mindspore.ops.HookBackward.rst index e118412ffe3..afd5b1d814a 100644 --- a/docs/api/api_python/ops/mindspore.ops.HookBackward.rst +++ b/docs/api/api_python/ops/mindspore.ops.HookBackward.rst @@ -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) - 需要导出的变量的梯度。 diff --git a/docs/api/api_python/ops/mindspore.ops.InvertPermutation.rst b/docs/api/api_python/ops/mindspore.ops.InvertPermutation.rst index 509fae3d261..26e2675e65b 100644 --- a/docs/api/api_python/ops/mindspore.ops.InvertPermutation.rst +++ b/docs/api/api_python/ops/mindspore.ops.InvertPermutation.rst @@ -18,4 +18,4 @@ mindspore.ops.InvertPermutation 异常: - **TypeError** - 如果 `input_x` 既不是tuple也不是list。 - - **TypeError** - 如果 `input_x` 的元素不是整数。 + - **TypeError** - 如果 `input_x` 的元素不是int。 diff --git a/docs/api/api_python/ops/mindspore.ops.LSTM.rst b/docs/api/api_python/ops/mindspore.ops.LSTM.rst index 5385a348257..f005c3cc32e 100644 --- a/docs/api/api_python/ops/mindspore.ops.LSTM.rst +++ b/docs/api/api_python/ops/mindspore.ops.LSTM.rst @@ -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。 diff --git a/docs/api/api_python/ops/mindspore.ops.Lerp.rst b/docs/api/api_python/ops/mindspore.ops.Lerp.rst index d1db1158bc3..8efeb308e34 100644 --- a/docs/api/api_python/ops/mindspore.ops.Lerp.rst +++ b/docs/api/api_python/ops/mindspore.ops.Lerp.rst @@ -3,6 +3,6 @@ mindspore.ops.Lerp .. py:class:: mindspore.ops.Lerp - 逐元素计算输入张量的最小值。 + 基于权重参数计算两个Tensor之间的线性插值。 有关更多详细信息,请参阅: :func:`mindspore.ops.lerp` 。 diff --git a/docs/api/api_python/ops/mindspore.ops.Multinomial.rst b/docs/api/api_python/ops/mindspore.ops.Multinomial.rst index 819fbcd23c5..593f2440f76 100644 --- a/docs/api/api_python/ops/mindspore.ops.Multinomial.rst +++ b/docs/api/api_python/ops/mindspore.ops.Multinomial.rst @@ -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类型。 diff --git a/docs/api/api_python/ops/mindspore.ops.func_count_nonzero.rst b/docs/api/api_python/ops/mindspore.ops.func_count_nonzero.rst index 6b717e9562f..daa6da09661 100644 --- a/docs/api/api_python/ops/mindspore.ops.func_count_nonzero.rst +++ b/docs/api/api_python/ops/mindspore.ops.func_count_nonzero.rst @@ -13,3 +13,8 @@ mindspore.ops.count_nonzero 返回: Tensor,非零元素的数量。数据类型由 `dtype` 所指定。 + + 异常: + - **TypeError** - `axis` 不是int、tuple或者list。 + - **ValueError** - `axis` 不在[-x.ndim, x.ndim)范围内。 + diff --git a/docs/api/api_python/ops/mindspore.ops.func_crop_and_resize.rst b/docs/api/api_python/ops/mindspore.ops.func_crop_and_resize.rst index 90c60bf49e1..78512f5f1e0 100644 --- a/docs/api/api_python/ops/mindspore.ops.func_crop_and_resize.rst +++ b/docs/api/api_python/ops/mindspore.ops.func_crop_and_resize.rst @@ -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。 返回: - Tensor,shape为 :math:`(num_boxes, crop_height, crop_width, depth)`,数据类型:float32 。 + Tensor,shape为(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` 不是浮点值。 diff --git a/docs/api/api_python/ops/mindspore.ops.func_cumsum.rst b/docs/api/api_python/ops/mindspore.ops.func_cumsum.rst index 115f35c4ccc..37531e567e1 100644 --- a/docs/api/api_python/ops/mindspore.ops.func_cumsum.rst +++ b/docs/api/api_python/ops/mindspore.ops.func_cumsum.rst @@ -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。 diff --git a/docs/api/api_python/ops/mindspore.ops.func_diagonal.rst b/docs/api/api_python/ops/mindspore.ops.func_diagonal.rst index 821a941f1e5..293db73465e 100644 --- a/docs/api/api_python/ops/mindspore.ops.func_diagonal.rst +++ b/docs/api/api_python/ops/mindspore.ops.func_diagonal.rst @@ -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。 diff --git a/docs/api/api_python/ops/mindspore.ops.func_div.rst b/docs/api/api_python/ops/mindspore.ops.func_div.rst index 82555973b87..4cd4a8b39ea 100644 --- a/docs/api/api_python/ops/mindspore.ops.func_div.rst +++ b/docs/api/api_python/ops/mindspore.ops.func_div.rst @@ -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"。 diff --git a/docs/api/api_python/ops/mindspore.ops.func_dropout.rst b/docs/api/api_python/ops/mindspore.ops.func_dropout.rst index 868358c7303..9eb747e47b4 100644 --- a/docs/api/api_python/ops/mindspore.ops.func_dropout.rst +++ b/docs/api/api_python/ops/mindspore.ops.func_dropout.rst @@ -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。 diff --git a/docs/api/api_python/ops/mindspore.ops.func_elu.rst b/docs/api/api_python/ops/mindspore.ops.func_elu.rst index d6365010d34..3dd9e068667 100644 --- a/docs/api/api_python/ops/mindspore.ops.func_elu.rst +++ b/docs/api/api_python/ops/mindspore.ops.func_elu.rst @@ -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 `_ 。 - .. 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 `_ 。 + 参数: - - **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` 相同。 diff --git a/docs/api/api_python/ops/mindspore.ops.func_expand.rst b/docs/api/api_python/ops/mindspore.ops.func_expand.rst index 8251951a5c5..4d53dfb0174 100644 --- a/docs/api/api_python/ops/mindspore.ops.func_expand.rst +++ b/docs/api/api_python/ops/mindspore.ops.func_expand.rst @@ -10,17 +10,17 @@ mindspore.ops.expand 参数: - **input_x** (Tensor) - 输入Tensor,shape为 :math:`(x_1, x_2, ..., x_R)` 。 - - **size** (Tensor) - `input_x` 的新shape大小。 + - **size** (Tensor) - `input_x` 扩展后的shape。 返回: - Tensor,其大小为 `size` 。 + Tensor,其shape为 `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。 diff --git a/docs/api/api_python/ops/mindspore.ops.func_fills.rst b/docs/api/api_python/ops/mindspore.ops.func_fills.rst index b31269abfeb..0c3a2642927 100644 --- a/docs/api/api_python/ops/mindspore.ops.func_fills.rst +++ b/docs/api/api_python/ops/mindspore.ops.func_fills.rst @@ -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。数据类型为int8,int16,int32,float16,float32。 + - **x** (Tensor) - 输入Tensor,用来指定输出Tensor的shape和dtype。数据类型为int8,int16,int32,float16,float32。 - **value** (Union[int, float, Tensor]) - 用来填充输出Tensor的值。数据类型为int,float或0维Tensor。 返回: - Tensor,与输入数据 `x` 具有相同的shape和type。 + Tensor,与输入数据 `x` 具有相同的shape和dtype。 异常: - **TypeError** - `x` 不是Tensor。 diff --git a/docs/api/api_python/ops/mindspore.ops.func_floor_mod.rst b/docs/api/api_python/ops/mindspore.ops.func_floor_mod.rst index f2fce9d66f9..46dd9f85414 100644 --- a/docs/api/api_python/ops/mindspore.ops.func_floor_mod.rst +++ b/docs/api/api_python/ops/mindspore.ops.func_floor_mod.rst @@ -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. diff --git a/docs/api/api_python/ops/mindspore.ops.func_gelu.rst b/docs/api/api_python/ops/mindspore.ops.func_gelu.rst index d533fdfe14b..67464c79fe0 100644 --- a/docs/api/api_python/ops/mindspore.ops.func_gelu.rst +++ b/docs/api/api_python/ops/mindspore.ops.func_gelu.rst @@ -30,4 +30,4 @@ mindspore.ops.gelu Tensor,具有与 `input_x` 相同的数据类型和shape。 异常: - - **TypeError** - `input_x` 的数据类型既不是float16也不是float32。 + - **TypeError** - `input_x` 的数据类型既不是float16、float32或者float64。 diff --git a/docs/api/api_python/ops/mindspore.ops.func_glu.rst b/docs/api/api_python/ops/mindspore.ops.func_glu.rst index 19e9be0033a..0eb9852e0c7 100644 --- a/docs/api/api_python/ops/mindspore.ops.func_glu.rst +++ b/docs/api/api_python/ops/mindspore.ops.func_glu.rst @@ -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 `_. 参数: - - **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。 diff --git a/docs/api/api_python/ops/mindspore.ops.func_laplace.rst b/docs/api/api_python/ops/mindspore.ops.func_laplace.rst index f8e2118d18a..c8f09f2204b 100644 --- a/docs/api/api_python/ops/mindspore.ops.func_laplace.rst +++ b/docs/api/api_python/ops/mindspore.ops.func_laplace.rst @@ -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。 diff --git a/docs/api/api_python/ops/mindspore.ops.func_lerp.rst b/docs/api/api_python/ops/mindspore.ops.func_lerp.rst index e15f4b6c00b..14d75519159 100644 --- a/docs/api/api_python/ops/mindspore.ops.func_lerp.rst +++ b/docs/api/api_python/ops/mindspore.ops.func_lerp.rst @@ -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。 返回: diff --git a/docs/api/api_python/ops/mindspore.ops.func_less.rst b/docs/api/api_python/ops/mindspore.ops.func_less.rst index 22bf226f5ab..b4638b80b4e 100644 --- a/docs/api/api_python/ops/mindspore.ops.func_less.rst +++ b/docs/api/api_python/ops/mindspore.ops.func_less.rst @@ -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} diff --git a/docs/api/api_python/ops/mindspore.ops.func_less_equal.rst b/docs/api/api_python/ops/mindspore.ops.func_less_equal.rst index 0352f9a12df..74aec8b7fd9 100644 --- a/docs/api/api_python/ops/mindspore.ops.func_less_equal.rst +++ b/docs/api/api_python/ops/mindspore.ops.func_less_equal.rst @@ -19,7 +19,7 @@ mindspore.ops.less_equal 参数: - **input** (Union[Tensor, number.Number, bool]) - 第一个输入,是一个number.Number、bool值或数据类型为 `number `_ 或 `bool_ `_ 的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。 返回: Tensor,shape与广播后的shape相同,数据类型为bool。 diff --git a/docs/api/api_python/ops/mindspore.ops.func_log_matrix_determinant.rst b/docs/api/api_python/ops/mindspore.ops.func_log_matrix_determinant.rst index 2f136ed8ccd..73620749a79 100644 --- a/docs/api/api_python/ops/mindspore.ops.func_log_matrix_determinant.rst +++ b/docs/api/api_python/ops/mindspore.ops.func_log_matrix_determinant.rst @@ -3,18 +3,18 @@ mindspore.ops.log_matrix_determinant .. py:function:: mindspore.ops.log_matrix_determinant(x) - 计算一个或多个平方矩阵行列式绝对值的对数的符号和绝对值的对数。 + 对一个或多个方阵行列式的绝对值取对数,返回其符号和值。 参数: - **x** (Tensor) - 输入Tensor,shape为 :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。 diff --git a/docs/api/api_python/ops/mindspore.ops.func_logit.rst b/docs/api/api_python/ops/mindspore.ops.func_logit.rst index 85bd3c68c96..91b4e8ec7a6 100644 --- a/docs/api/api_python/ops/mindspore.ops.func_logit.rst +++ b/docs/api/api_python/ops/mindspore.ops.func_logit.rst @@ -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。 返回: diff --git a/docs/api/api_python/ops/mindspore.ops.func_matrix_determinant.rst b/docs/api/api_python/ops/mindspore.ops.func_matrix_determinant.rst index 526f77a5ffd..8fae763dfda 100644 --- a/docs/api/api_python/ops/mindspore.ops.func_matrix_determinant.rst +++ b/docs/api/api_python/ops/mindspore.ops.func_matrix_determinant.rst @@ -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。 diff --git a/docs/api/api_python/ops/mindspore.ops.func_mean.rst b/docs/api/api_python/ops/mindspore.ops.func_mean.rst index a99a81b0e00..c61a090c8de 100644 --- a/docs/api/api_python/ops/mindspore.ops.func_mean.rst +++ b/docs/api/api_python/ops/mindspore.ops.func_mean.rst @@ -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` 超出范围。 diff --git a/docs/api/api_python/ops/mindspore.ops.func_median.rst b/docs/api/api_python/ops/mindspore.ops.func_median.rst index 7b15601bc0d..a4ad619ecf7 100644 --- a/docs/api/api_python/ops/mindspore.ops.func_median.rst +++ b/docs/api/api_python/ops/mindspore.ops.func_median.rst @@ -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。 返回: diff --git a/docs/api/api_python/ops/mindspore.ops.func_multinomial.rst b/docs/api/api_python/ops/mindspore.ops.func_multinomial.rst index 3e4559b2c98..42a672130f3 100644 --- a/docs/api/api_python/ops/mindspore.ops.func_multinomial.rst +++ b/docs/api/api_python/ops/mindspore.ops.func_multinomial.rst @@ -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。 返回: diff --git a/mindspore/python/mindspore/ops/composite/math_ops.py b/mindspore/python/mindspore/ops/composite/math_ops.py index e4979934d75..fdd36615be1 100644 --- a/mindspore/python/mindspore/ops/composite/math_ops.py +++ b/mindspore/python/mindspore/ops/composite/math_ops.py @@ -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`` diff --git a/mindspore/python/mindspore/ops/composite/random_ops.py b/mindspore/python/mindspore/ops/composite/random_ops.py index 9bedba70d25..7656fbc4e4c 100644 --- a/mindspore/python/mindspore/ops/composite/random_ops.py +++ b/mindspore/python/mindspore/ops/composite/random_ops.py @@ -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. diff --git a/mindspore/python/mindspore/ops/function/array_func.py b/mindspore/python/mindspore/ops/function/array_func.py index 78765e559ac..afb60de9eee 100644 --- a/mindspore/python/mindspore/ops/function/array_func.py +++ b/mindspore/python/mindspore/ops/function/array_func.py @@ -4517,19 +4517,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: @@ -4681,21 +4682,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. diff --git a/mindspore/python/mindspore/ops/function/image_func.py b/mindspore/python/mindspore/ops/function/image_func.py index 26add20bcf3..6dac5043e17 100644 --- a/mindspore/python/mindspore/ops/function/image_func.py +++ b/mindspore/python/mindspore/ops/function/image_func.py @@ -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). diff --git a/mindspore/python/mindspore/ops/function/math_func.py b/mindspore/python/mindspore/ops/function/math_func.py index d171b508409..81c17b43031 100644 --- a/mindspore/python/mindspore/ops/function/math_func.py +++ b/mindspore/python/mindspore/ops/function/math_func.py @@ -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: @@ -3853,7 +3856,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. @@ -4279,7 +4282,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:: @@ -4767,9 +4770,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. @@ -6508,10 +6511,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: diff --git a/mindspore/python/mindspore/ops/function/nn_func.py b/mindspore/python/mindspore/ops/function/nn_func.py index 41dde7d74fb..3008045a942 100644 --- a/mindspore/python/mindspore/ops/function/nn_func.py +++ b/mindspore/python/mindspore/ops/function/nn_func.py @@ -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. @@ -3771,14 +3772,15 @@ def glu(x, axis=-1): See `Language Modeling with Gated Convluational Networks `_. 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: @@ -3870,8 +3872,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). @@ -3892,7 +3892,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'. @@ -3946,7 +3946,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 `_ . diff --git a/mindspore/python/mindspore/ops/function/sparse_func.py b/mindspore/python/mindspore/ops/function/sparse_func.py index d6a8ccda901..d4c69daec7b 100644 --- a/mindspore/python/mindspore/ops/function/sparse_func.py +++ b/mindspore/python/mindspore/ops/function/sparse_func.py @@ -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`` diff --git a/mindspore/python/mindspore/ops/operations/array_ops.py b/mindspore/python/mindspore/ops/operations/array_ops.py index 3a2f3cdc359..d46db9d851f 100755 --- a/mindspore/python/mindspore/ops/operations/array_ops.py +++ b/mindspore/python/mindspore/ops/operations/array_ops.py @@ -5748,9 +5748,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. @@ -6824,8 +6824,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: diff --git a/mindspore/python/mindspore/ops/operations/debug_ops.py b/mindspore/python/mindspore/ops/operations/debug_ops.py index a8704fe88ea..feaf168c35e 100644 --- a/mindspore/python/mindspore/ops/operations/debug_ops.py +++ b/mindspore/python/mindspore/ops/operations/debug_ops.py @@ -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. diff --git a/mindspore/python/mindspore/ops/operations/image_ops.py b/mindspore/python/mindspore/ops/operations/image_ops.py index 96565ff1699..0f3b16c37a7 100644 --- a/mindspore/python/mindspore/ops/operations/image_ops.py +++ b/mindspore/python/mindspore/ops/operations/image_ops.py @@ -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. diff --git a/mindspore/python/mindspore/ops/operations/math_ops.py b/mindspore/python/mindspore/ops/operations/math_ops.py index 76c6554375a..0290e253e17 100644 --- a/mindspore/python/mindspore/ops/operations/math_ops.py +++ b/mindspore/python/mindspore/ops/operations/math_ops.py @@ -2425,7 +2425,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. @@ -2603,8 +2604,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. @@ -2612,12 +2613,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`` @@ -3016,7 +3017,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 `_ or - `bool_ `_. + `bool_ `_. - **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\_. @@ -3858,7 +3859,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. @@ -4172,7 +4173,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: diff --git a/mindspore/python/mindspore/ops/operations/nn_ops.py b/mindspore/python/mindspore/ops/operations/nn_ops.py index 2d0d465c2f2..aa2cb9ecf45 100644 --- a/mindspore/python/mindspore/ops/operations/nn_ops.py +++ b/mindspore/python/mindspore/ops/operations/nn_ops.py @@ -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: @@ -7042,12 +7042,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