Skip to content

[Feature request] torch.isnan and torch.nan #4767

@mdraw

Description

@mdraw

I know it's possible to check for NaN values of torch tensors by using the numpy.isnan() function on CPU tensors, but I think a native torch.isnan() function would be nice to have. I would also propose a constant torch.nan similar to numpy.nan that can be assigned (or compared) to torch tensors for testing purposes.

My main use case for this is that I want to automatically check losses for NaN values during training and warn the user or terminate training when encountering them.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions