mindspore.numpy.argmax

mindspore.numpy.argmax(a, axis=None)[源代码]

Returns the indices of the maximum values along an axis.

Note

Numpy argument out is not supported. On Ascend, in case of multiple occurrences of the maximum values, the return indices may not necessarily correspond to the first occurrence.

Parameters
  • a (Union[int, float, bool, list, tuple, Tensor]) – Input array.

  • axis (int, optional) – By default, the index is into the flattened array, otherwise along the specified axis. Default: None.

Returns

Tensor, array of indices into the array. It has the same shape as a.shape with the dimension along axis removed.

Raises

ValueError – If axis is out of range.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore.numpy as np
>>> a = np.arange(10, 16).reshape(2, 3)
>>> print(np.argmax(a))
5
>>> print(np.argmax(a, axis=0))
[1 1 1]
>>> print(np.argmax(a, axis=1))
[2 2]