PyTorch torch.fmin function
PyTorch torch reference manual
torch.fmin A function in PyTorch for element-wise minimum (ignoring NaN). When the input contains NaN, torch.minimum returns NaN, while torch.fmin ignores NaN and returns a non-NaN value.
Function definition
torch.fmin(input, other)
Usage examples
Example
import
torch
Create a tensor containing NaN
x
=
torch.
tensor
(
[
3.0
,
float
(
'nan'
)
,
4.0
]
)
y
=
torch.
tensor
(
[
1.0
,
5.0
,
2.0
]
)
Element-wise minimum (ignoring NaN)
result
=
torch.
fmin
(
x
,
y
)
(
result
)
The output is:
tensor([1., 5., 2.])