mindspore.Tensor.argmin
- Tensor.argmin(axis=None, keepdims=False) Tensor
Returns the indices of the minimum values along the given axis of the tensor.
- Parameters
- Returns
Tensor
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore >>> x = mindspore.tensor([[2, 5, 1, 6], ... [3, -7, -2, 4], ... [8, -4, 1, -3]]) >>> # case 1: By default, compute the minimum of all elements. >>> x.argmin() Tensor(shape=[], dtype=Int32, value= 5) >>> >>> # case 2: Compute the minimum along axis 1. >>> x.argmin(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. >>> x.argmin(axis=1, keepdims=True) Tensor(shape=[3, 1], dtype=Int32, value= [[2], [1], [1]])
- Tensor.argmin(dim=None, keepdim=False) Tensor
Returns the indices of the minimum values along the given axis of the tensor.
- Parameters
- Returns
Tensor
- Supported Platforms:
Ascend
Examples
>>> import mindspore >>> x = mindspore.tensor([[2, 5, 1, 6], ... [3, -7, -2, 4], ... [8, -4, 1, -3]]) >>> # case 1: By default, compute the minimum of all elements. >>> x.argmin() Tensor(shape=[], dtype=Int32, value= 5) >>> >>> # case 2: Compute the minimum along dim 1. >>> x.argmin(dim=1) Tensor(shape=[3], dtype=Int32, value= [2, 1, 1]) >>> >>> # case 3: If keepdim=True, the output shape will be same of that of the input. >>> x.argmin(dim=1, keepdim=True) Tensor(shape=[3, 1], dtype=Int32, value= [[2], [1], [1]])