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
© 2026, PyTorch Contributors
PyTorch has a BSD-style license, as found in the LICENSE file.
https://docs.pytorch.org/docs/2.14/generated/torch.complex.html