Is there an isinf function in PyTorch?

Does PyTorch have a function to perform an equivalent of NumPy np.isinf, for Tensor objects? I have searched throughout the docs but I did not find anything.

1 Like

You can do something like:

import torch
x = torch.zeros(10)
y = 1/x  # tensor with all infinities
y == float('inf')
1 Like