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