Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PyTorch torch.argmin function

PyTorch torch.argmin function


PyTorch torch reference manual 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

]

]

)

print

(

"Global minimum index:"

,

torch.

argmin

(

x

)

)

print

(

"dim=1 minimum index:"

,

torch.

argmin

(

x

,

dim

=

1

)

)

The output is:

全局最小索引: tensor(0)

dim=1 最小索引: tensor([0, 1])


PyTorch torch reference manual PyTorch torch reference manual