mindspore.mint.argmax

View Source On Gitee
mindspore.mint.argmax(input) Tensor[source]

Return the indices of the maximum values of a tensor.

Parameters

input (Tensor) – Input tensor.

Returns

Tensor.

Supported Platforms:

Ascend

Examples

>>> import numpy as np
>>> from mindspore import Tensor
>>> from mindspore import mint
>>> x = Tensor(np.array([[1, 20, 5], [67, 8, 9], [130, 24, 15]]).astype(np.float32))
>>> output = mint.argmax(x)
>>> print(output)
6
mindspore.mint.argmax(input, dim, keepdim=False) Tensor[source]

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

Parameters
  • input (Tensor) – Input tensor.

  • dim (int) – The dimension to reduce.

  • keepdim (bool, optional) – Whether the output tensor retains the specified dimension. Default: False .

Returns

Tensor, indices of the maximum values across a dimension.

Raises
Supported Platforms:

Ascend

Examples

>>> import numpy as np
>>> from mindspore import Tensor
>>> from mindspore import mint
>>> x = Tensor(np.array([[1, 20, 5], [67, 8, 9], [130, 24, 15]]).astype(np.float32))
>>> output = mint.argmax(x, dim=-1)
>>> print(output)
[1 0 0]