PyTorch torch.isposinf Function


Pytorch torch 参考手册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)

The output result is:

tensor([False, True, False, False])

Pytorch torch 参考手册Pytorch torch Reference Manual

Other Extensions