mindspore.ops.argmax

mindspore.ops.argmax(x, axis=None, keepdims=False)[source]

Return the indices of the maximum values of a tensor across a dimension.

Parameters
  • x (Tensor) – Input tensor.

  • axis (Union[int, None], optional) – The dimension to reduce. If axis is None, the indices of the maximum value within the flattened input will be returned. 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 maximum values across a dimension.

Raises

ValueError – If axis is out of range.

Supported Platforms:

Ascend GPU CPU

Examples

>>> x = Tensor(np.array([[1, 20, 5], [67, 8, 9], [130, 24, 15]]).astype(np.float32))
>>> output = ops.argmax(x, axis=-1)
>>> print(output)
[1 0 0]