mindspore.mint.argmax

查看源文件
mindspore.mint.argmax(input) Tensor[源代码]

返回tensor的最大值索引。

参数:
  • input (Tensor) - 输入tensor。

返回:

Tensor。

支持平台:

Ascend

样例:

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

返回tensor在指定维度上的最大值索引。

参数:
  • input (Tensor) - 输入tensor。

  • dim (int) - 指定维度。

  • keepdim (bool,可选) - 是否保留输出tensor的维度。默认 False

返回:

Tensor

异常:
  • ValueError - 如果 dim 的设定值超出了范围。

支持平台:

Ascend

样例:

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