mindspore.ops.ArgMinWithValue
- class mindspore.ops.ArgMinWithValue(axis=0, keep_dims=False)[source]
Calculates the minimum value along with the given axis for the input tensor, and returns the minimum values and indices.
Note
In auto_parallel and semi_auto_parallel mode, the first output index can not be used.
Warning
If there are multiple minimum values, the index of the first minimum value is used.
The value range of axis is [-dims, dims - 1]. “dims” is the dimension length of input.
Also see
mindspore.ops.min()
.- Parameters
- Inputs:
input (Tensor) - The input tensor, can be any dimension. Set the shape of input tensor as \((input_1, input_2, ..., input_N)\) .Complex tensor is not supported.
- Outputs:
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, with dtype int64. If keep_dims is
True
, the shape of output tensors is \((input_1, input_2, ..., input_{axis-1}, 1, input_{axis+1}, ..., input_N)\). Otherwise, the shape is \((input_1, input_2, ..., input_{axis-1}, input_{axis+1}, ..., input_N)\) .values (Tensor) - The minimum value of input tensor, with the same shape as index, and same dtype as input.
- Raises
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore >>> import numpy as np >>> from mindspore import Tensor, ops >>> x = Tensor(np.array([0.0, 0.4, 0.6, 0.7, 0.1]), mindspore.float32) >>> index, output = ops.ArgMinWithValue()(x) >>> print(index, output) 0 0.0 >>> index, output = ops.ArgMinWithValue(keep_dims=True)(x) >>> print(index, output) [0] [0.0]