一树梨花压海棠什么意思

paddle. as_complex ( x: Tensor, name: str | None = None ) Tensor [source]
百度 ”磕磕绊绊又运行了5个月,跟头里总结经验,流程越跑越顺,选品越来越精,成本也有效得到了控制,王杰的公司总算稳定下来。

Transform a real tensor to a complex tensor.

The data type of the input tensor is ‘float32’ or ‘float64’, and the data type of the returned tensor is ‘complex64’ or ‘complex128’, respectively.

The shape of the input tensor is (* ,2), (* means arbitrary shape), i.e. the size of the last axis should be 2, which represent the real and imag part of a complex number. The shape of the returned tensor is (*,).

The image below demonstrates the case that a real 3D-tensor with shape [2, 3, 2] is transformed into a complex 2D-tensor with shape [2, 3].

Illustration of as_complex
Parameters
  • x (Tensor) – The input tensor. Data type is ‘float32’ or ‘float64’.

  • name (str|None, optional) – Name for the operation (optional, default is None). For more information, please refer to Name.

Returns

Tensor, The output. Data type is ‘complex64’ or ‘complex128’, with the same precision as the input.

Examples

>>> import paddle
>>> x = paddle.arange(12, dtype=paddle.float32).reshape([2, 3, 2])
>>> y = paddle.as_complex(x)
>>> print(y)
Tensor(shape=[2, 3], dtype=complex64, place=Place(cpu), stop_gradient=True,
[[1j      , (2+3j)  , (4+5j)  ],
 [(6+7j)  , (8+9j)  , (10+11j)]])