Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PyTorch torch.isneginf function

PyTorch torch.isneginf function


PyTorch torch reference manual PyTorch torch reference manual

torch.isneginf is a function in PyTorch used to check for negative infinity. It returns a Boolean tensor where each element is True if it is negative infinity.

Function definition

torch.isneginf(input)


Usage examples

Example

import

torch

Create a tensor containing different numerical values

x

=

torch.

tensor

(

[

1.0

,

float

(

'inf'

)

,

float

(

'-inf'

)

,

2.0

]

)

Check for negative infinity

result

=

torch.

isneginf

(

x

)

print

(

result

)

The output is:

tensor([False, False, True, False])


PyTorch torch reference manual PyTorch torch reference manual