mindspore.Tensor.argmin
- Tensor.argmin(axis=None, keepdims=False) Tensor
Returns the indices of the minimum value of self across the axis.
If the shape of self is \((self_1, ..., self_N)\), the shape of the output tensor is \((self_1, ..., self_{axis-1}, self_{axis+1}, ..., self_N)\).
- Parameters
axis (Union[int, None], optional) – Axis where the Argmin operation applies to. If None, it will return the index of the minimum value in the flattened Tensor along the specified axis. Default:
None
.keepdims (bool, optional) – Whether the output tensor retains the specified dimension. Ignored if axis is None. Default:
False
.
- Returns
Tensor, indices of the min value of self across the axis.
- Raises
TypeError – If axis is not an int.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore >>> import numpy as np >>> from mindspore import Tensor, ops >>> input_x = Tensor(np.array([2.0, 3.1, 1.2]), mindspore.float32) >>> index = Tensor.argmin(input_x) # input_x.argmin() >>> print(index) 2
- Tensor.argmin(dim=None, keepdim=False) Tensor
Returns the indices of the minimum value of self across the dim.
If the shape of self is \((self_1, ..., self_N)\), the shape of the output tensor is \((self_1, ..., self_{dim-1}, self_{dim+1}, ..., self_N)\).
- Parameters
dim (Union[int, None], optional) – Dimension where the Argmin operation applies to. If None, it will return the index of the minimum value in the flattened Tensor along the specified dimension. Default:
None
.keepdim (bool, optional) – Whether the output tensor retains the specified dimension. Ignored if dim is None. Default:
False
.
- Returns
Tensor, indices of the min value of self across the dimension.
- Raises
TypeError – If dim is not an int.
- Supported Platforms:
Ascend
Examples
>>> import mindspore >>> import numpy as np >>> from mindspore import Tensor, ops >>> input_x = Tensor(np.array([2.0, 3.1, 1.2]), mindspore.float32) >>> index = Tensor.argmin(input_x) # input_x.argmin() >>> print(index) 2