PyTorch torch.is_floating_point Function


Pytorch torch 参考手册PyTorch torch Reference Manual

torch.is_floating_pointIt is a function in PyTorch used to check whether the data type of a tensor is a floating-point type.

Function Definition

torch.is_floating_point(input)

Usage Example

Example

import torch

# Floating-point tensor
x = torch.tensor([1.0, 2.0, 3.0])
print("Floating point:", torch.is_floating_point(x))

# Integer tensor
y = torch.tensor([1, 2, 3])
print("Integer:", torch.is_floating_point(y))

The output result is:

浮点数: True
整数: False

Pytorch torch 参考手册PyTorch torch Reference Manual

Other Extensions