PyTorch torch.isposinf Function
Pytorch torch Reference Manual
torch.isposinfis a function in PyTorch used to check whether it is positive infinity. Returns a boolean tensor that is True for each element if it is positive infinity.
Function Definition
torch.isposinf(input)
Usage Example
Example
import torch
# Create a tensor containing different values
x = torch.tensor([1.0, float('inf'), float('-inf'), 2.0])
# Check if it is positive infinity
result = torch.isposinf(x)
print(result)
# Create a tensor containing different values
x = torch.tensor([1.0, float('inf'), float('-inf'), 2.0])
# Check if it is positive infinity
result = torch.isposinf(x)
print(result)
The output result is:
tensor([False, True, False, False])
Other Extensions