torch.complex#
- torch.complex(real, imag, *, out=None) Tensor#
構造一個實部等於
real,虛部等於imag的複數張量。- 引數
- 關鍵字引數
out (Tensor) – 如果輸入是
torch.float32,則必須是torch.complex64。如果輸入是torch.float64,則必須是torch.complex128。
示例
>>> real = torch.tensor([1, 2], dtype=torch.float32) >>> imag = torch.tensor([3, 4], dtype=torch.float32) >>> z = torch.complex(real, imag) >>> z tensor([(1.+3.j), (2.+4.j)]) >>> z.dtype torch.complex64