PyTorch torch.is_floating_point function
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
]
)
(
"Float:"
,
torch.
is_floating_point
(
x
)
)
Integer tensor
y
=
torch.
tensor
(
[
1
,
2
,
3
]
)
(
"Integer:"
,
torch.
is_floating_point
(
y
)
)
The output is:
浮点数: True
整数: False