pypose.hasnan¶
- class pypose.hasnan(obj)[source]¶
Checks whether a deep nested list of tensors contains Nan or not.
- Parameters:
obj (
obj
) – a Python object that can be a list of nested list.- Returns:
True
if the list contains a tensor withNan
otherwiseFalse
.- Return type:
bool
Example
>>> L1 = [[1, 3], [4, [5, 6]], 7, [8, torch.tensor([0, -1.0999])]] >>> hasnan(L1) False >>> L2 = [[torch.tensor([float('nan'), -1.0999]), 3], [4, [5, 6]], 7, [8, 9]] >>> hasnan(L2) True >>> L3 = [[torch.tensor([1, -1.0999]), 3], [4, [float('nan'), 6]], 7, [8, 9]] >>> hasnan(L3) True