Skip to content

[feature request] torch.isinf, torch.isfinite #9132

@vadimkantorov

Description

@vadimkantorov

Exists in numpy: https://docs.scipy.org/doc/numpy/reference/generated/numpy.isinf.html (https://docs.scipy.org/doc/numpy/reference/generated/numpy.isfinite.html) and tensorflow https://www.tensorflow.org/api_docs/python/tf/is_inf (https://www.tensorflow.org/api_docs/python/tf/is_finite)

Useful for debugging checks like

assert not (torch.isnan(x).any() or torch.isinf(x).any())

Much more concise than

assert not (torch.isnan(x).any() or x.eq(float('inf')).any() or x.eq(float('-inf')).any())

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions