PyTorch torch.isneginf Function
Pytorch torch Reference Manual
torch.isneginfIt is a function in PyTorch used to check for negative infinity. Returns a boolean tensor where each element is True if it is negative infinity.
Function Definition
torch.isneginf(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 negative infinity
result = torch.isneginf(x)
print(result)
# Create a tensor containing different values
x = torch.tensor([1.0, float('inf'), float('-inf'), 2.0])
# Check if it is negative infinity
result = torch.isneginf(x)
print(result)
The output result is:
tensor([False, False, True, False])
Other Extensions