class paddle.fluid.ComplexVariable(real, imag)[source]

The Variable defined on the complex number domain. It contains two common real number Variables as its members, real and imag holding the real part and imaginary part of complex numbers respectively.


The constructor of ComplexVariable should not be invoked directly.

Only support dygraph mode at present. Please use to_variable to create a dygraph ComplexVariable with complex number data.

  • real (Variable) – The Variable holding real-part data.

  • imag (Variable) – The Variable holding imaginery-part data.


import paddle.fluid as fluid
import numpy as np

a = np.array([1.0+2.0j, 0.2])
with fluid.dygraph.guard():
    var = fluid.dygraph.to_variable(a, name="new_var")
    print(, var.dtype, var.shape)
    # ({'real': u'new_var.real', 'imag': u'new_var.imag'}, 'complex128', [2L])
    # [1. +2.j 0.2+0.j]