I could not find inf module in torch

someone is importing this from torch import inf but it is giving error and when I searched also could not find this module in torch documention. can anybody explain the reason

I’m not aware of such a module so do you know what it’s supposed to contain? Or do you mean torch.isinf?

not torch.isinf. It was importing like I stated above

In that case it might not be a module but the infinity definition. What kind of error are you seeing?

importerror: cannot import name ‘inf’ from ‘torch’

It works for me:

>>> from torch import inf
>>> inf
inf
>>> import torch
>>> torch.tensor(inf)
tensor(inf)
>>> 1. / torch.tensor(inf)
tensor(0.)
>>> torch.tensor(inf) / torch.tensor(inf)
tensor(nan)
>>> inf / inf
nan

so you might need to update your PyTorch version.

Thank you. I changed to np.inf that works for me because I could not update Pytorch due CUDA version.