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

PyTorch torch.isposinf function

PyTorch torch.isposinf function


PyTorch torch reference manual PyTorch torch reference manual

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

Function definition

torch.isposinf(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 positive infinity

result

=

torch.

isposinf

(

x

)

print

(

result

)

The output is:

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


PyTorch torch reference manual PyTorch torch reference manual