評價此頁

torch.is_floating_point#

torch.is_floating_point(input: Tensor) bool#

如果 input 的資料型別是浮點資料型別,則返回 True,即 torch.float64torch.float32torch.float16torch.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