This application discloses a training method and related apparatus for a
quantum generative adversarial network (GAN), belonging to the field of
quantum computing technology. The GAN includes a generator and a
discriminator. The method includes: using the generator to obtain generated samples against
random noise; using the
discriminator to distinguish between real samples and the generated samples, obtaining a discrimination result; updating the parameters of the generator and the
discriminator based on the discrimination result, the
loss function of the generator, and the
loss function of the discriminator, to obtain a trained GAN. At least one of the generator and the discriminator includes a
quantum convolutional layer and a quantum residual neural module connected sequentially. The quantum residual neural module includes a first
qubit and a second
qubit for encoding and evolving each
feature data. Two qubits; a first
quantum logic gate and a second
quantum logic gate acting on the first
qubit for performing an
identity mapping operation on
feature data; a third
quantum logic gate acting on the second qubit and entangled with the first qubit between the first and second quantum logic gates, wherein the third quantum
logic gate includes an encoding module for encoding
feature data and parameterized training logic gates located before and after the encoding module for implementing residuals, and the encoding module includes an encoding
logic gate and entanglement gates located before and after the encoding
logic gate, the entanglement gates realizing the entanglement of the first and second qubits; the second qubit corresponding to one feature data at an adjacent position is the first qubit corresponding to another feature data, the feature data being obtained based on a quantum convolutional layer. Applying this application can effectively suppress the gradient vanishing problem and reduce the waste of training resources caused by training failures.