mindspore.ops.ArgMinWithValue
- class mindspore.ops.ArgMinWithValue(*args, **kwargs)[source]
Calculates the minimum value with corresponding index, and returns indices and values.
Calculates the minimum value along with the given axis for the input tensor. It returns the minimum values and indices.
Note
In auto_parallel and semi_auto_parallel mode, the first output index can not be used.
- Parameters
- Inputs:
input_x (Tensor) - The input tensor, can be any dimension. Set the shape of input tensor as \((x_1, x_2, ..., x_N)\).
- 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. If keep_dims is true, the shape of output tensors is \((x_1, x_2, ..., x_{axis-1}, 1, x_{axis+1}, ..., x_N)\). Otherwise, the shape is \((x_1, x_2, ..., x_{axis-1}, x_{axis+1}, ..., x_N)\). - output_x (Tensor) - The minimum value of input tensor, with the same shape as index.
- Supported Platforms:
Ascend
CPU
Examples
>>> input_x = Tensor(np.array([0.0, 0.4, 0.6, 0.7, 0.1]), mindspore.float32) >>> output = ops.ArgMinWithValue()(input_x) >>> print(output) (Tensor(shape=[], dtype=Int32, value= 0), Tensor(shape=[], dtype=Float32, value= 0.0)) >>> output = ops.ArgMinWithValue(keep_dims=True)(input_x) >>> print(output) (Tensor(shape=[1], dtype=Int32, value= [0]), Tensor(shape=[1], dtype=Float32, value= [0.0]))