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

PyTorch torch.amin function

PyTorch torch.amin function


PyTorch torch reference manual PyTorch torch reference manual

torch.amin is a function in PyTorch used to return the minimum value of a tensor along a specified dimension.

Function definition

torch.amin(input, dim, keepdim=False)


Usage examples

Example

import

torch

x

=

torch.

tensor

(

[

[

1

,

3

,

2

]

,

[

4

,

1

,

3

]

]

)

Return the minimum of all elements

print

(

"Global minimum:"

,

torch.

amin

(

x

)

)

Minimum along dim=0

print

(

"dim=0 minimum:"

,

torch.

amin

(

x

,

dim

=

0

)

)

Minimum along dim=1

print

(

"dim=1 minimum:"

,

torch.

amin

(

x

,

dim

=

1

)

)

The output is:

全局最小: tensor(1)

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

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


PyTorch torch reference manual PyTorch torch reference manual