mindspore.ops.argmin

mindspore.ops.argmin(input, axis=None, keepdims=False)[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
  • input (Tensor) – Input tensor. The shape is \((N,*)\) where \(*\) means, any number of additional dimensions.

  • axis (Union[int, None], optional) – Axis where the Argmin operation applies to. Default: None.

  • keepdims (bool, optional) – Whether the output tensor retains the specified dimension. Ignored if axis is None. Default: False.

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