diff --git a/docs/api/api_python/mindspore/mindspore.Tensor.rst b/docs/api/api_python/mindspore/mindspore.Tensor.rst index a5ff115a61b..88d9862fef8 100644 --- a/docs/api/api_python/mindspore/mindspore.Tensor.rst +++ b/docs/api/api_python/mindspore/mindspore.Tensor.rst @@ -90,6 +90,36 @@ mindspore.Tensor Tensor。如果在指定轴方向上所有Tensor元素都为True,则其值为True,否则其值为False。如果轴为None或空元组,则默认降维。 + .. py:method:: arg_min_with_value(axis=0, keep_dims=False) + + 根据指定的索引计算最小值,并返回索引和值。 + + 在给定轴上计算输入Tensor的最小值,并且返回最小值和索引。 + + .. note:: + 在auto_parallel和semi_auto_parallel模式下,不能使用第一个输出索引。 + + .. warning:: + - 如果有多个最小值,则取第一个最小值的索引。 + - `axis` 的取值范围为[-dims, dims - 1]。`dims` 为输入Tensor的维度长度。 + + **参数:** + + - **axis** (int) - 指定计算维度。默认值:0。 + - **keep_dims** (bool) - 表示是否减少维度。如果为True,则输出维度和输入维度相同。如果为False,则减少输出维度。默认值:False。 + + **返回:** + + tuple (Tensor),表示2个Tensor组成的tuple,包含对应的索引和输入Tensor的最小值。 + + - **index** (Tensor) - 输入Tensor最小值的索引。如果 `keep_dims` 为True,则输出Tensor的shape为 :math:`(x_1, x_2, ..., x_{axis-1}, 1, x_{axis+1}, ..., x_N)` 。否则,shape为 :math:`(x_1, x_2, ..., x_{axis-1}, x_{axis+1}, ..., x_N)` 。 + - **output_x** (Tensor) - 输入Tensor的最小值,其shape与索引相同。 + + **异常:** + + - **TypeError** - `keep_dims` 不是bool。 + - **TypeError** - `axis` 不是int。 + .. py:method:: argmax(axis=None) 返回指定轴上最大值的索引。 diff --git a/mindspore/python/mindspore/ops/operations/array_ops.py b/mindspore/python/mindspore/ops/operations/array_ops.py index 2e5f36ab219..dab130cbef6 100755 --- a/mindspore/python/mindspore/ops/operations/array_ops.py +++ b/mindspore/python/mindspore/ops/operations/array_ops.py @@ -2218,10 +2218,10 @@ class ArgMinWithValue(Primitive): tuple (Tensor), tuple of 2 tensors, containing the corresponding index and the minimum value of the input tensor. - - index (Tensor) - The index for the minimum value of the input tensor. If `keep_dims` is true, the shape of + - **index** (Tensor) - The index for the minimum value of the input tensor. If `keep_dims` is true, the shape of output tensors is :math:`(x_1, x_2, ..., x_{axis-1}, 1, x_{axis+1}, ..., x_N)`. Otherwise, the shape is :math:`(x_1, x_2, ..., x_{axis-1}, x_{axis+1}, ..., x_N)` . - - values (Tensor) - The minimum value of input tensor, with the same shape as index. + - **values** (Tensor) - The minimum value of input tensor, with the same shape as index. Raises: TypeError: If `keep_dims` is not a bool.