用法
torch.is_complex(input)
主要功能:判断输入input是否为复数形式
参数
input:输入
结果输出
如果input是复数形式,则返回True,否则返回False,其中复数形式分为complex64和complex128
例子
>>> a=torch.tensor([2,3],dtype=torch.float32)
>>> b=torch.tensor([3,4],dtype=torch.float32)
>>> c=torch.complex(a,b)
>>> print(c.dtype)
torch.complex64
>>> print(torch.is_complex(c))
True
>>> a=torch.tensor([2,3],dtype=torch.double)
>>> b=torch.tensor([2,3],dtype=torch.double)
>>> c=torch.complex(a,b)
>>> print(c.dtype)
torch.complex128
>>> print(torch.is_complex(c))
True