PyTorch torch.argmin function
PyTorch torch reference manual
torch.argmin is a function in PyTorch used to return the index of the minimum value along a dimension.
Function definition
torch.argmin(input, dim, keepdim)
Usage examples
Example
import
torch
x
=
torch.
tensor
(
[
[
1
,
3
,
2
]
,
[
4
,
1
,
3
]
]
)
(
"Global minimum index:"
,
torch.
argmin
(
x
)
)
(
"dim=1 minimum index:"
,
torch.
argmin
(
x
,
dim
=
1
)
)
The output is:
全局最小索引: tensor(0)
dim=1 最小索引: tensor([0, 1])