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

PyTorch torch.is_floating_point function

PyTorch torch.is_floating_point function


PyTorch torch reference manual PyTorch torch reference manual

torch.is_floating_point A function in PyTorch for checking whether a tensor's data type is a floating-point type.

Function definition

torch.is_floating_point(input)


Usage examples

Example

import

torch

Floating-point tensor

x

=

torch.

tensor

(

[

1.0

,

2.0

,

3.0

]

)

print

(

"Float:"

,

torch.

is_floating_point

(

x

)

)

Integer tensor

y

=

torch.

tensor

(

[

1

,

2

,

3

]

)

print

(

"Integer:"

,

torch.

is_floating_point

(

y

)

)

The output is:

浮点数: True

整数: False


PyTorch torch reference manual PyTorch torch reference manual