torch.is_complex#
- torch.is_complex(input: Tensor) bool#
如果
input的資料型別是複數資料型別,即torch.complex64和torch.complex128之一,則返回 True。- 引數
input (Tensor) – 輸入張量。
示例
>>> torch.is_complex(torch.tensor([1, 2, 3], dtype=torch.complex64)) True >>> torch.is_complex(torch.tensor([1, 2, 3], dtype=torch.complex128)) True >>> torch.is_complex(torch.tensor([1, 2, 3], dtype=torch.int32)) False >>> torch.is_complex(torch.tensor([1.0, 2.0, 3.0], dtype=torch.float16)) False