mindspore.Tensor.argmin_with_value

Tensor.argmin_with_value(axis=0, keep_dims=False)[source]

Returns the minimum value with corresponding index.

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 this tensor.

Parameters
  • axis (int) – The dimension to reduce. Default: 0.

  • keep_dims (bool) – Whether to reduce dimension, if true the output will keep the same dimension as the input, the output will reduce dimension if false. Default: False.

Returns

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)\) .

  • value (Tensor) - The minimum value of input tensor, with the same shape as index.

Raises
Supported Platforms:

Ascend GPU CPU

Examples

>>> x = Tensor(np.array([0.0, 0.4, 0.6, 0.7, 0.1]), mindspore.float32)
>>> output, index = x.argmin_with_value()
>>> print(output, index)
0.0 0
>>> output, index = x.argmin_with_value(keep_dims=True)
>>> print(output, index)
[0.0] [0]