Match any "pathological" elements in Tensor

Hi, I want to check whether my tensor has any pathological elements at all, like inf, NaN, etc. I don’t know what the exhaustive list is for all such pathologies. Please help!

In some packages there are super-classes that contain all pathologies, and you just check for instances of that.


To check for valid values only, you could use torch.isfinite(tensor).
You could also check explicitly for NaNs or Infs via torch.isnan(tensor) and torch.isinf(tensor).