fn

argmin

Tensor
argmin(x: Tensor, dim: _int | None = None, keepdim: _bool = False)
source

Return the indices of the minimum values along dim.

Symmetric to argmax — for each slice along dim the index of the smallest element is produced, with ties broken by returning the first occurrence in row-major order. dim=None reduces over the flattened tensor.

Parameters

xTensor
Input tensor.
dimint= None
Reduction dimension. None reduces over all elements.
keepdimbool= False
Whether to keep the reduced dim with size 1.

Returns

Tensor

int64 index tensor.

Notes

argmin(x)=argmini  xi.\mathrm{argmin}(x) = \underset{i}{\arg\min}\; x_i.

Examples

>>> import lucid
>>> x = lucid.tensor([3.0, 1.0, 4.0, 1.0])
>>> lucid.argmin(x)
Tensor(1)