mindspore.ops.argmin

mindspore.ops.argmin(x, axis=- 1)[source]

Returns the indices of the minimum value of a tensor across the axis.

If the shape of input tensor is \((x_1, ..., x_N)\), the shape of the output tensor is \((x_1, ..., x_{axis-1}, x_{axis+1}, ..., x_N)\).

Parameters
  • x (Tensor) – Input tensor. The shape is \((N,*)\) where \(*\) means, any number of additional dimensions.

  • axis (int) – Axis where the Argmin operation applies to. Default: -1.

Returns

Tensor, indices of the min value of input tensor across the axis.

Raises

TypeError – If axis is not an int.

Supported Platforms:

Ascend GPU CPU

Examples

>>> input_x = Tensor(np.array([2.0, 3.1, 1.2]), mindspore.float32)
>>> index = ops.argmin(input_x)
>>> print(index)
2