YouTip LogoYouTip

Pytorch Torch Isinf

# PyTorch torch.isinf Function * * Pytorch torch Reference Manual](#) `torch.isinf` is a function in PyTorch used to check if a value is infinite. It returns a boolean tensor where each element is True if it is infinite (positive infinity or negative infinity). ### Function Definition torch.isinf(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 values are infinite result = torch.isinf(x) print(result) The output result is: tensor([False, True, True, False]) * * Pytorch torch Reference Manual](#)
← Pytorch Torch IsneginfPytorch Torch Isfinite β†’