mindspore.ops.Argmax

class mindspore.ops.Argmax(axis=- 1, output_type=mstype.int32)[source]

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

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

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

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

Inputs:
  • input_x (Tensor) - Input tensor. \((N,*)\) where \(*\) means, any number of additional dimensions. Support data type list as follows:

    • Ascend: Float16, Float32.

    • GPU: Float16, Float32.

    • CPU: Float16, Float32, Float64.

Outputs:

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

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([[1, 20, 5], [67, 8, 9], [130, 24, 15]]).astype(np.float32))
>>> output = ops.Argmax(output_type=mindspore.int32)(input_x)
>>> print(output)
[1 0 0]