torch.is_floating_point#
- torch.is_floating_point(input: Tensor) bool #
如果
input
的数据类型是浮点数据类型,则返回 True,即torch.float64
、torch.float32
、torch.float16
和torch.bfloat16
之一。- 参数
input (Tensor) – 输入张量。
示例
>>> torch.is_floating_point(torch.tensor([1.0, 2.0, 3.0])) True >>> torch.is_floating_point(torch.tensor([1, 2, 3], dtype=torch.int32)) False >>> torch.is_floating_point(torch.tensor([1.0, 2.0, 3.0], dtype=torch.float16)) True >>> torch.is_floating_point(torch.tensor([1, 2, 3], dtype=torch.complex64)) False