mindspore.ops.argmin

View Source On Gitee
mindspore.ops.argmin(input, axis=None, keepdims=False)[source]

Return the indices of the minimum values along a specified dimension of the tensor.

Parameters
  • input (Tensor) – The input tensor.

  • axis (Union[int, None], optional) – Specify the dimension for computation. If None , compute all elements in the input . Default None .

  • keepdims (bool, optional) – Whether the output tensor has dim retained. Default False .

Returns

Tensor

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> input = mindspore.tensor([[2, 5, 1, 6],
...                           [3, -7, -2, 4],
...                           [8, -4, 1, -3]])
>>> # case 1: By default, compute the minimum indice of all elements.
>>> mindspore.ops.argmin(input)
Tensor(shape=[], dtype=Int32, value= 5)
>>>
>>> # case 2: Compute the minimum indices along axis 1.
>>> mindspore.ops.argmin(input, axis=1)
Tensor(shape=[3], dtype=Int32, value= [2, 1, 1])
>>>
>>> # case 3: If keepdims=True, the output shape will be same of that of the input.
>>> mindspore.ops.argmin(input, axis=1, keepdims=True)
Tensor(shape=[3, 1], dtype=Int32, value=
[[2],
 [1],
 [1]])