mindspore.ops.Argmin

class mindspore.ops.Argmin(axis=- 1, output_type=mstype.int32)[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
  • axis (int) – Axis where the Argmin operation applies to. Default: -1.

  • output_type (mindspore.dtype) – An optional data type of mindspore.dtype.int32 and mindspore.dtype.int64. Default: mindspore.dtype.int32.

Inputs:
  • input_x (Tensor) - Input tensor. The shape is \((N,*)\) where \(*\) means, any number of additional dimensions.

    • Ascend: Float16, Float32, Float64, Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64.

Outputs:

Tensor, whose dtype is determined by output_type.

Raises
  • TypeError – If axis is not an int.

  • TypeError – If output_type is neither int32 nor int64.

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