torch.view_as_complex
-
torch.view_as_complex(input) → Tensor
-
Returns a view of
input
as a complex tensor. For an input complex tensor ofsize
, this function returns a new complex tensor ofsize
where the last dimension of the input tensor is expected to represent the real and imaginary components of complex numbers.Warning
view_as_complex()
is only supported for tensors withtorch.dtype
torch.float64
andtorch.float32
. The input is expected to have the last dimension ofsize
2. In addition, the tensor must have astride
of 1 for its last dimension. The strides of all other dimensions must be even numbers.- Parameters
-
input (Tensor) – the input tensor.
- Example::
-
>>> x=torch.randn(4, 2) >>> x tensor([[ 1.6116, -0.5772], [-1.4606, -0.9120], [ 0.0786, -1.7497], [-0.6561, -1.6623]]) >>> torch.view_as_complex(x) tensor([(1.6116-0.5772j), (-1.4606-0.9120j), (0.0786-1.7497j), (-0.6561-1.6623j)])
© 2019 Torch Contributors
Licensed under the 3-clause BSD License.
https://pytorch.org/docs/1.8.0/generated/torch.view_as_complex.html