PyTorch torch.isposinf function
PyTorch torch reference manual
torch.isposinf is a function in PyTorch used to check for positive infinity. It returns a Boolean tensor where each element is True if it is positive infinity.
Function definition
torch.isposinf(input)
Usage examples
Example
import
torch
Create a tensor containing different numerical values
x
=
torch.
tensor
(
[
1.0
,
float
(
'inf'
)
,
float
(
'-inf'
)
,
2.0
]
)
Check for positive infinity
result
=
torch.
isposinf
(
x
)
(
result
)
The output is:
tensor([False, True, False, False])