view_as_real
- paddle. view_as_real ( input: Tensor ) Tensor [source]
-
Return a real tensor that is a view of the input complex tensor.
The data type of the input tensor is ‘complex64’ or ‘complex128’, and the data type of the returned tensor is ‘float32’ or ‘float64’, respectively.
When the shape of the input tensor is
(*, )
, (*
means arbitrary shape), the shape of the output tensor is(*, 2)
, i.e. the shape of the output is the shape of the input appended by an extra2
.The real tensor is a view of the input complex tensor, meaning that it shares the same memory with complex tensor.
- Parameters
-
input (Tensor) – The input tensor. Data type is ‘complex64’ or ‘complex128’.
- Returns
-
Tensor, The output. Data type is ‘float32’ or ‘float64’, sharing the same memory with input.
Examples
>>> import paddle >>> x = paddle.arange(12, dtype=paddle.float32).reshape([2, 3, 2]) >>> y = paddle.as_complex(x) >>> z = paddle.as_real(y) >>> print(z) Tensor(shape=[2, 3, 2], dtype=float32, place=Place(cpu), stop_gradient=True, [[[0. , 1. ], [2. , 3. ], [4. , 5. ]], [[6. , 7. ], [8. , 9. ], [10., 11.]]])