PyTorch torch.amin function
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
(
"Global minimum:"
,
torch.
amin
(
x
)
)
Minimum along dim=0
(
"dim=0 minimum:"
,
torch.
amin
(
x
,
dim
=
0
)
)
Minimum along dim=1
(
"dim=1 minimum:"
,
torch.
amin
(
x
,
dim
=
1
)
)
The output is:
全局最小: tensor(1)
dim=0 最小: tensor([1, 1, 2])
dim=1 最小: tensor([1, 1])