A training method of a quantum generative adversarial network and a related device
By introducing quantum convolutional layers and quantum residual neural modules, quantum generative adversarial networks solve the gradient vanishing problem in classical generative adversarial networks, achieving more efficient training and better quality generated samples, while reducing resource waste.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ORIGIN QUANTUM COMPUTING TECH (HEFEI) CO LTD
- Filing Date
- 2025-07-21
- Publication Date
- 2026-06-26
AI Technical Summary
Classical generative adversarial networks are prone to the vanishing gradient problem during training, which makes it difficult for the generator to learn the real data distribution. The generated samples are simple and cannot effectively generate complex samples, resulting in a waste of training resources.
A quantum generative adversarial network is adopted, which is trained using quantum convolutional layers and quantum residual neural modules. The stable propagation and entanglement of gradients are achieved through quantum logic gates and entanglement gates, which enhances the network's expressive power and flexibility and avoids gradient vanishing.
It effectively suppresses the gradient vanishing problem, improves the diversity and quality of generated samples, reduces the waste of training resources, and enhances the training efficiency and effectiveness of generative adversarial networks.
Smart Images

Figure CN122287769A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of quantum computing technology, and in particular to a training method and related apparatus for quantum generative adversarial networks. Background Technology
[0002] Generative Adversarial Networks (GANs) are an important generative model in deep learning. The generator and discriminator are trained simultaneously and compete in a minimax algorithm. This adversarial approach avoids some of the difficulties of traditional generative models in practical applications, cleverly approximating some unsolvable loss functions through adversarial learning. GANs have wide applications in the generation of data such as images, videos, natural language, and music.
[0003] In classic generative adversarial networks (GANs), the generator and discriminator compete against each other during training. When the discriminator becomes too powerful and easily distinguishes between generated and real samples, the gradients returned by the discriminator to the generator become very small, resulting in the vanishing gradient problem. This makes it difficult for the generator to update its parameters and effectively learn the distribution of real data, limiting it to generating only simple, fixed samples.
[0004] When the generator only outputs similar samples, the discriminator's input (real samples + generated samples) shows a highly concentrated distribution of generated samples. The discriminator gradually becomes lazy—it no longer needs to learn complex real distribution features and can distinguish samples based on simple patterns (e.g., "all generated samples are a certain color"). At this point, the discriminator's gradient feedback loses its guiding significance, failing to help the generator optimize and degenerating into an inefficient model. This bidirectional failure renders the entire GAN an "ineffective model," unusable for generation tasks and unable to assist other tasks (such as anomaly detection), wasting significant training resources. Summary of the Invention
[0005] The purpose of this application is to provide a training method and related apparatus for quantum generative adversarial networks, which aims to effectively suppress the gradient vanishing problem and reduce the waste of training resources caused by training failure.
[0006] One embodiment of this application provides a training method for a quantum generative adversarial network, the quantum generative adversarial network including a generator and a discriminator, the method comprising: Using a generator, generated samples are obtained for random noise; The discriminator is used to distinguish between real samples and generated samples to obtain a discrimination result; Based on the discrimination result, the loss function of the generator, and the loss function of the discriminator, the parameters of the generator and the discriminator are updated to obtain the trained quantum generative adversarial network. At least one of the generator and the discriminator includes a quantum convolutional layer and a quantum residual neural module connected in sequence. The quantum residual neural module includes: a first qubit and a second qubit for encoding and evolving each feature data; a first quantum logic gate and a second quantum logic gate acting on the first qubit for performing an identity mapping operation on the feature data; and a third quantum logic gate acting on the second qubit and entangled with the first qubit between the first and second quantum logic gates. The third quantum logic gate includes an encoding module for encoding the feature data and parameterized training logic gates located before and after the encoding module for implementing residuals. The encoding module includes an encoding logic gate and entanglement gates located before and after the encoding logic gates, and the entanglement gates implement entanglement between 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, and the feature data is obtained based on the quantum convolutional layer.
[0007] Optionally, the training of the generator and the training of the discriminator can be performed alternately.
[0008] Optionally, the quantum convolutional layer is a quantum void convolutional layer.
[0009] Optionally, the first quantum logic gate and the second quantum logic gate are quantum logic gates of the same type.
[0010] Optionally, the first quantum logic gate and the second quantum logic gate are H-gates or parametric quantum logic gates.
[0011] Optionally, when the first quantum logic gate and the second quantum logic gate are H gates, the parameterized training logic gate and the first quantum logic gate are of different types, and the quantum circuit obtains the residual based on the evolution result of the feature data by the parameterized training logic gate.
[0012] Optionally, when the first quantum logic gate and the second quantum logic gate are parametric quantum logic gates, the parameterized training logic gate and the first quantum logic gate are of the same type, and the quantum circuit obtains the residual based on the evolution results of the feature data by the parameterized training logic gate, the first quantum logic gate, and the second quantum logic gate.
[0013] Another embodiment of this application provides a training device for a quantum generative adversarial network, wherein the quantum generative adversarial network includes a generator and a discriminator, and the device includes: The sample generation module is used to generate samples for random noise using a generator. The discrimination result acquisition module is used to use the discriminator to discriminate between the real sample and the output result to obtain the discrimination result; A training module is used to update 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 quantum generative adversarial network. At least one of the generator and the discriminator includes a quantum convolutional layer and a quantum residual neural module connected in sequence. The quantum residual neural module includes: a first qubit and a second qubit for encoding and evolving each feature data; a first quantum logic gate and a second quantum logic gate acting on the first qubit for performing an identity mapping operation on the feature data; and a third quantum logic gate acting on the second qubit and entangled with the first qubit between the first and second quantum logic gates. The third quantum logic gate includes an encoding module for encoding the feature data and parameterized training logic gates located before and after the encoding module for implementing residuals. The encoding module includes an encoding logic gate and entanglement gates located before and after the encoding logic gates, and the entanglement gates implement entanglement between 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, and the feature data is obtained based on the quantum convolutional layer.
[0014] Another embodiment of this application provides a computer device including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the training method of the quantum generative adversarial network in any of the above embodiments.
[0015] Another embodiment of this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a computer, causes the computer to perform the training method for the quantum generative adversarial network in any of the above embodiments.
[0016] This application reduces the risk of overfitting by decreasing the number of parameters through quantum convolutional layers, which helps maintain gradient stability. The introduction of quantum residual neural modules enables the network to avoid the vanishing gradient problem while maintaining the entanglement and evolution of quantum states using residual connection mechanisms. Specifically, the use of entanglement gates achieves effective entanglement between qubits, enhancing the expressive power of quantum states. Entangled states provide more quantum information, helping to maintain the magnitude of gradients during training and thus reducing the possibility of gradient vanishing. Parameterized training logic gates endow the network with the ability to learn and adjust the evolution of quantum states to better adapt to training data. This parameterization method increases the network's flexibility and helps avoid gradient vanishing during training. Furthermore, qubits of adjacent feature data form chain entanglement through a sharing mechanism, constructing long-distance dependencies across modules. This structure is similar to the attention mechanism in Transformer models, allowing gradients to propagate efficiently through entangled links, rather than relying solely on layer-by-layer propagation. Therefore, this application effectively suppresses the vanishing gradient problem and reduces the waste of training resources caused by training failures by introducing quantum residual neural modules and quantum convolutional layers. Attached Figure Description
[0017] Figure 1 An example system block diagram of a training method for a quantum generative adversarial network provided in an embodiment of this application; Figure 2 A flowchart illustrating a training method for a quantum generative adversarial network provided in an embodiment of this application; Figure 3 This application provides a schematic diagram of the structure of a quantum circuit corresponding to a quantum spatial convolutional layer. Figure 4 A schematic diagram of a quantum residual block provided in an embodiment of this application; Figure 5 A schematic diagram of the structure of a training device for a quantum generative adversarial network provided in an embodiment of this application. Figure 6 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation
[0018] The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain this application, and should not be construed as limiting this application.
[0019] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0020] Classical computers use transistors to encode information in binary data, such as bits, where each bit can represent a value of 1 or 0. These 1s and 0s act as switches to drive the functions of a classical computer. If there are n bits of data, there are 2^n possible classical states, and one state is represented at a time.
[0021] Quantum computers use quantum processors that operate on data represented by qubits, also known as quantum bits. A qubit can represent the classical binary states "0" or "1", or a superposition of "0" and "1". Because it can represent a superposition of "0" and "1", a qubit can represent both "0" and "1" states simultaneously. For example, if there are n bits of data, n quantum states can be represented simultaneously. Furthermore, qubits in a superposition can be correlated with each other, a phenomenon known as entanglement. The state of one qubit (whether it's 1, 0, or both) can depend on the state of another qubit, and more information can be encoded within two entangled qubits. Based on the principles of superposition and entanglement, qubits enable quantum computers to perform functions that might be relatively complex and time-consuming for classical computers.
[0022] Please refer to Figure 1 This illustration shows an example system block diagram of a training method for a quantum generative adversarial network provided in one embodiment of this application. The system can be a hybrid computing system comprising a combination of one or more quantum computers, quantum systems, and / or classical computers. Figure 1 In the example shown, the system may include quantum hardware 11 and classical hardware 12. In one implementation, quantum hardware 11 and classical hardware 12 may be configured to communicate via one or more wired and / or wireless connections (e.g., wireless networks). Quantum hardware 11 may include a quantum chipset consisting of one or more quantum chips, comprising various hardware components for processing data encoded in qubits. The quantum chipset may be a quantum computing core surrounded by infrastructure to protect the quantum chips from electromagnetic noise sources, mechanical vibration sources, heat sources, and other noise sources that can degrade the performance of the quantum chips. Classical hardware 12 may be electronically integrated with quantum hardware 11 via any suitable wired and / or wireless electronic connection.
[0023] exist Figure 1In the example shown, quantum hardware 11 can be any suitable set of components capable of performing quantum operations on a physical system. Quantum operations, for example, can be quantum logic gate operations that manipulate the quantum states of qubits to evolve and / or become entangled. Figure 1 In the illustrated example embodiment, quantum hardware 11 may include a measurement and control unit 111, an interface 112, and a quantum chip 113. In some embodiments, all or part of each of the measurement and control unit 111, interface 112, and quantum chip 113 may be located in a cryogenic environment to facilitate the performance of quantum operations. Quantum chip 113 may be any hardware capable of processing information using quantum states. This hardware may include multiple qubits and means for coupling or entanglement of the qubits to process information using quantum states. Qubits may include, but are not limited to, charge qubits, flux qubits, phase qubits, spin qubits, and ion qubits. The quantum chip may include a set of quantum logic gates configured to perform quantum logic operations on the qubits stored in a quantum register. Quantum gates may include one or more single-qubit gates, two-qubit gates, and / or other multi-qubit gates.
[0024] The measurement and control unit 111 can be any combination of digital computing devices capable of performing quantum computing (e.g., executing quantum circuits) in conjunction with interface 112. This digital computing device may include a digital processor and memory for storing and executing quantum instructions using interface 112. The digital computing device may also include a communication protocol device for receiving instructions and sending the results of the performed quantum computing to a classical computer. Additionally, the digital computing device may include a communication interface with interface 112. In one embodiment, the measurement and control unit 111 may be configured to receive classical instructions (e.g., from classical hardware 12) and convert these classical instructions into measurement and control instructions for interface 112. The measurement and control instructions provided by the measurement and control unit 111 to interface 112 may be, for example, digital signals indicating which quantum gates in a quantum gate array need to be applied to the qubits to perform a specific function. Interface 112 may be configured to convert these digital signals into analog signals (e.g., analog pulses of microwave pulses), which can be used to apply quantum gates to the qubits to manipulate the interactions between the qubits.
[0025] Interface 112 may be a classical-quantum interface, comprising a combination of devices capable of receiving instructions from the integrated measurement and control unit 111 and converting those instructions into a means for implementing quantum operations. In one embodiment, interface 112 may convert instructions from the integrated measurement and control unit 111 into drive signals capable of driving or manipulating qubits, and / or applying quantum gates to qubits. Additionally, interface 112 may be configured to convert signals received from the quantum chip 113 into digital signals capable of being processed and transmitted by the integrated measurement and control unit 111. Devices included in interface 112 may include, but are not limited to, digital-to-analog converters, analog-to-digital converters, waveform generators, attenuators, amplifiers, optical fibers, lasers, and filters. Interface 112 may further include circuitry configured to measure multiple qubits after a quantum gate is applied, wherein the measurement may produce results represented in classical bits. Each measurement performed by interface 112 may be read out to a device connected to quantum hardware 11, such as classical hardware 12. The multiple measurement results provided by interface 112 may represent probabilistic results.
[0026] Classical hardware 12 can include hardware components such as processors and storage devices (e.g., including memory devices and classical registers) for processing data encoded in classical bits. In one embodiment, classical hardware 12 can be configured to provide quantum hardware 11 with various control signals, instructions, and data encoded in classical bits. Further, quantum states measured by quantum hardware 11 can be read out by classical hardware 12, and classical hardware 12 can store the measured quantum states as classical bits in classical registers. In one embodiment, classical hardware 12 can be any suitable combination of computer-executable hardware and / or computer-executable software capable of executing computation module 122 to perform quantum computation using data stored in storage module 121 as part of the construction and computation. Storage module 121 can be a repository for data to be analyzed using quantum computing algorithms and the results of that analysis. Computation module 122 can be a program or module capable of preparing classical data from storage module 121 as part of a quantum circuit implementation. Computation module 122 can be instantiated as part of a larger algorithm, such as a function call to an application programming interface (API), or by resolving hybrid classical-quantum computing into aspects of quantum and classical computing. For example, computing module 122 can generate instructions for creating quantum circuits using quantum gates. In an embodiment, such instructions can be stored by the measurement and control unit 111 and executed by instantiating components of interface 112, so that quantum operations of quantum gates can be performed on quantum chip 113.
[0027] Classic hardware 12 can be a laptop computer, desktop computer, vehicle-integrated computer, smart mobile device, tablet device, and / or any other suitable classic computing device. Additionally or alternatively, classic hardware 12 can also operate as part of a cloud computing service model, such as Software as a Service (SaaS), Platform as a Service (PaaS), or Infrastructure as a Service (IaaS). Classic hardware 12 can also reside in a cloud computing deployment model, such as a private cloud, community cloud, public cloud, or hybrid cloud.
[0028] See Figure 2 , Figure 2 The training method for a quantum generative adversarial network provided in this application includes the following steps: S201: Use the generator to obtain generated samples for random noise.
[0029] Random noise (a low-dimensional vector following a normal or uniform distribution) is the initial input to the generator. Its main function is to provide a source of diversity for the generator; different noises should correspond to different generated samples (e.g., different noises generate different faces), ensuring that the diversity of generated samples matches the diversity of the real sample set. The generator performs a nonlinear transformation on the input random noise, ultimately outputting generated samples with the same dimensions as the real samples. For example, if the real sample is an image, the random noise, after processing by the generator, will become a pixel matrix with the same size and number of channels as the real sample (e.g., a face or landscape photo). The type of the generated samples is consistent with the type of the real samples.
[0030] The core goal of a generator is to make the generated samples as close as possible to the real samples in terms of visual features (such as the texture and structure of an image) or statistical distribution (such as the mean, variance, and higher-order correlation of data), ultimately achieving a "deceptive" effect. Random noise itself does not directly contain information about the real samples. The essence of a generator is to learn a mapping function so that the probability distribution of the generated samples, after being mapped, can approximate the probability distribution of the real samples.
[0031] S202: Use the discriminator to distinguish between the real sample and the generated sample to obtain the discrimination result.
[0032] The discriminator's role is to determine whether a generated sample is genuine. It assigns the highest possible probability to genuine samples and the lowest possible probability to generated samples. The discriminator's result is a probability value representing the probability that the input sample is a genuine sample.
[0033] S203: Based on the discrimination result, the loss function of the generator, and the loss function of the discriminator, update the parameters of the generator and the discriminator to obtain the trained quantum generative adversarial network. At least one of the generator and the discriminator includes a quantum convolutional layer and a quantum residual neural module connected in sequence. The quantum residual neural module includes: a first qubit and a second qubit for encoding and evolving each feature data; a first quantum logic gate and a second quantum logic gate acting on the first qubit for performing an identity mapping operation on the feature data; and a third quantum logic gate acting on the second qubit for feature data encoding and parameterization training, and entangled with the first qubit between the first and second quantum logic gates. The third quantum logic gate includes an encoding module for feature data encoding and parameterization training logic gates located before and after the encoding module. The encoding module includes an encoding logic gate and entanglement gates located before and after the encoding logic gates. The entanglement gates achieve entanglement between the first and second qubits. The second qubit corresponding to the preceding feature data at adjacent temporal positions is the first qubit corresponding to the following feature data.
[0034] Both the generator and the discriminator have their own loss functions. The generator's loss function reflects the difference between generated and real samples, aiming to minimize this difference. The discriminator's loss function reflects its accuracy in distinguishing between real and generated samples, aiming to maximize its accuracy. By training the generator and discriminator using this strategy, the generator's generated samples become increasingly closer to real samples, while the discriminator becomes increasingly unable to distinguish between real and generated samples. This process iterates until the discriminator can no longer differentiate between real and generated samples.
[0035] In this application, the quantum generative adversarial network can be a fully quantum generative adversarial network, that is, it includes a quantum generator and a quantum discriminator, both of which may include sequentially connected quantum convolutional layers and quantum residual neural modules; or it can be a hybrid quantum generative adversarial network, which may specifically include a quantum generator and a classical discriminator, or a classical discriminator and a quantum hybrid.
[0036] Quantum convolutional layers extract features from input data through parameterized quantum gates, which can include single-qubit gates and two-qubit gates. A quantum convolutional layer typically consists of multiple parameterized quantum filters, similar to classical convolutional kernels. Each quantum filter is composed of a series of quantum gates, such as rotation gates (RX, RY, RZ) and controlled-NOT gates (CNOT). The parameters of these quantum gates can be optimized through a training process to extract feature information from the input data, thus obtaining feature data.
[0037] Through convolutional layers, the discriminator can extract features such as edges, textures, and shapes from the input data, thereby determining whether the input sample is a real sample. Convolutional layers help the generator learn how to generate samples with similar features from noise. Through convolutional operations, the generator can progressively construct samples similar to real samples.
[0038] In the quantum residual neural network module, the first qubit carries the initial state or the quantum state it previously held when it was the second qubit. The first and second quantum logic gates on the first qubit are responsible for the identity mapping. The identity mapping is an operation that directly connects the input to the output. The first and second quantum logic gates acting on the first qubit implement this operation, thus forming a skip connection.
[0039] In this application, a first qubit and a second qubit, a first quantum logic gate and a second quantum logic gate acting on the first qubit, and a third quantum logic gate acting on the second qubit for feature data encoding and parameterization training, and which is entangled with the first qubit between the first quantum logic gate and the second quantum logic gate, can form a quantum residual block.
[0040] In addition, the second qubit of an adjacent feature data is the first qubit of the next feature, forming a chain structure. The second qubit is used to encode and evolve the feature data and pass it on to the next feature. Thus, adjacent feature data can achieve information transmission and processing through the "multiplexing" of qubits.
[0041] The third quantum logic gate, while realizing the entanglement of the first and second qubits, also includes an encoding module and two parameterized training logic gates (one before and one after) to achieve nonlinear transformation of features. The encoding module is responsible for encoding the current feature data into a quantum state using the encoding logic gates. These encoding logic gates are quantum logic gates used to encode feature data; specifically, they can be rotation logic gates. Each feature data is mapped to the rotation angle parameter of the corresponding rotation logic gate through angle encoding. The two entanglement gates control the state of the second qubit through the quantum state of the first qubit; that is, the control bit of the entanglement gate is the first qubit. The entanglement gates are located before and after the encoding logic gates. The pre-entanglement gate can initialize or enhance the correlation between bits before encoding, while the post-entanglement gate consolidates or extends this correlation after encoding. The parameterized training logic gates are parameterized quantum logic gates whose parameters are updated through training to implement the residual mechanism; one is located before the encoding module, and the other is located after the encoding module. The two parameterized training logic gates are used to learn how to transform and adjust the encoded data. They are the core adjustable part of the residual learning capability. Specifically, they learn how to combine or fuse the quantum state after it has been transformed by the encoding module with the information passed from the front-end parameterized training logic gate (or a certain transformation of the original input).
[0042] The parameterized training logic gate, located before the encoding module, preprocesses the initial state of the second qubit, placing it in a "ready state" suitable for receiving encoded information. This is similar to the first convolutional layer of a residual block in a classical network, used to extract basic features, but the difference is that there is no input x at this point. The entanglement gate, located before the encoding logic gate, connects the "ready state" to the previous quantum residual block (e.g., ...). Figure 1 Entangling the processing results of the basic unit shown can create favorable conditions for subsequent feature fusion. This entanglement makes the states of the two qubits no longer independent, allowing the current quantum residual block to naturally carry the feature correlation of the previous quantum residual block, realizing "feature inheritance across residual blocks". It organically combines the feature information processed by the previous quantum residual block with the "ready state" of the current qubit, so that the feature information will not have a gap or abrupt change during the transmission process, but can be smoothly transitioned and accumulated. Then, through subsequent encoding operations, new feature information can be more effectively integrated into the existing feature system, thereby realizing the gradual accumulation and enhancement of features.
[0043] Entanglement gates deeply correlate the encoded quantum state with the state of the first qubit, deeply integrating key information extracted from the previous feature data into the processing of the current feature data. This deep correlation allows feature information to be more effectively transmitted and fused in the quantum residual network, avoiding isolated processing of feature information and thus enhancing the integrity and coherence of the features. The previous feature data, after processing, has already extracted important feature information. Deeply correlating it with the current feature data is equivalent to introducing "historical experience" into the processing of the current feature data, enabling the current feature data to inherit and enhance the key information from the previous feature data, thereby better capturing the overall characteristics and complex patterns of the data in subsequent processing. Quantum entanglement can tightly correlate the states between different qubits, making the relationships between feature dimensions more complex and rich. Through this structure, the correlation between the previous and current feature data is no longer a simple linear combination, but a complex nonlinear relationship achieved through quantum entanglement. This nonlinear relationship can more accurately describe the interactions between features, thereby improving the richness and accuracy of feature representation. Because the previous feature data has already extracted important feature information after processing, deeply correlating it with the current feature data makes the quantum circuit more robust when processing the current feature data. Even if there is noise or outliers in the current feature data, the key information in the previous feature data can play a certain "corrective" role in the processing of the current feature data, thereby improving the network's robustness to noise and outliers.
[0044] The learnable parameters of parameterized training logic gates can adaptively adjust the probability amplitude weights of different feature components. By deeply associating the previous feature data with the current feature data, the circuit can better assess the relative importance between different feature data and dynamically adjust the feature weights based on this importance. This adaptive weight adjustment mechanism allows the circuit to more accurately retain the "importance weights" of key features, thereby optimizing feature weight allocation, improving the efficiency and accuracy of feature extraction, and thus better focusing on key information in subsequent processing, enhancing the sensitivity and recognition ability of generative adversarial networks to key features.
[0045] Encoding gates, through encoding operations, can deeply fuse the current feature data with the processing results of previous feature data, generating more complex feature representations. The encoded quantum state is further processed through a second entanglement gate. This step further enhances the correlation between quantum states, enabling feature information to be transferred and fused more effectively between qubits.
[0046] The parameterized training logic gate following the encoding module operates on the quantum state processed by the second entanglement gate. This step is similar to the subsequent convolution and activation of the residual block in a classical network, used to further adjust and optimize the feature representation. The quantum state (which already contains feature difference information of x) is optimized by adjusting parameters to enhance the probability amplitude of key features and suppress noise, thereby achieving "precise purification" of the residual F(x).
[0047] In the generator, the quantum residual neural network module superimposes shallow low-level features with deep high-level features (such as semantic structure), avoiding deep features from overwriting shallow information. This allows the generated samples to simultaneously possess detail realism and global consistency (for example, when generating images, it ensures both clear local textures and reasonable overall composition). In the discriminator, the quantum residual neural network module allows features of different depths (such as low-level texture features and high-level semantic features) to participate in the decision-making process, reducing misjudgments caused by the lack of features at a single level and enhancing the ability to identify the "fakeness" of generated samples.
[0048] This application replicates the core logic of classical residual blocks through a structure of "identity mapping (first qubit, first quantum logic gate and second quantum logic gate) + residual learning (parameterization gate and encoding of the second qubit) + quantum fusion (entanglement gate and superposition state)". Preserve original features (identity mapping); Learn residual features (parameterized gate encoding of current data, entanglement injection of historical correlations); The output of the two is a quantum superposition state, which breaks through the limitation of classical linear fusion.
[0049] Meanwhile, by utilizing the superposition, entanglement, and unitarity of quantum computing, problems such as the dimensionality bottleneck, gradient vanishing, and inter-block correlation limitations of classical residual blocks are solved, thus realizing a "quantum version of residual blocks".
[0050] The following section provides a detailed explanation of why this application can suppress the gradient vanishing problem: The quantum residual neural module fundamentally suppresses the vanishing gradient problem by integrating the underlying properties of quantum computing (such as unitarity and entanglement) with the core logic of classical residual networks (identity mapping + residual learning). The main reason is: The parameterized training logic gate is essentially a unitary transformation. The derivative of this transformation (the Jacobian matrix) has a unit norm during backpropagation. This means that the norm of the gradient remains unchanged during propagation, unlike some activation functions in classic networks (such as the Sigmoid), which cause the gradient to shrink exponentially as the derivative approaches zero. Unitarity ensures the stability of gradient propagation.
[0051] The quantum residual neural module uses entanglement gates to associate the output of the previous quantum residual block with the input state of the current residual block, thus achieving nonlocal gradient propagation. The gradient of the entangled quantum state can be propagated between different residual blocks through quantum mutual information. For example, the parameter gradient of the current quantum residual block depends not only on local operations but also on implicit feedback from the state of the previous residual block. This design forms a global gradient path, avoiding the problem of local gradient vanishing. Furthermore, the control bits of the entanglement gate (such as the state of the previous block) can dynamically adjust the gradient weights of the current block based on the complexity of the features. The qubits of adjacent feature data form a chain of entanglement through a sharing mechanism, constructing long-distance dependencies across modules. This structure is similar to the attention mechanism in the Transformer model, allowing gradients to propagate efficiently through entangled links, rather than simply relying on layer-by-layer propagation.
[0052] Parameterized training logic gates can use parameter shift rules to update parameters. This method avoids the decay problem of the chain rule in classical backpropagation. Even if the depth of the quantum residual neural module increases, gradient degradation will not occur.
[0053] Based on the above introduction, the following section details why quantum generative adversarial networks can effectively suppress the gradient vanishing problem: Classical generators are prone to losing effective training signals during backpropagation due to vanishing discriminator gradients (e.g., premature discriminator convergence). When a quantum residual neural module is located within the generator, the introduction of a quantum residual network addresses this problem through the following mechanism: The quantum residual neural module transmits gradients through the Jacobian matrix (unit norm) of the unitary transformation, ensuring that the gradient signal returned from the discriminator does not decay as it passes through the generator. Even when the discriminator output approaches 0 or 1 (a typical scenario of gradient vanishing in traditional GANs), the quantum generator maintains a stable gradient flow. The parameter updates of the quantum generator do not rely on traditional chain rule differentiation; instead, they calculate the gradient through direct difference of quantum expectation values (parameter shift rule), fundamentally avoiding the gradient degradation problem caused by increasing generator depth.
[0054] If a classical discriminator converges too quickly (e.g., easily outputting 0 to generated samples), it can cause the generator gradient to vanish. When a quantum residual neural module is located within the discriminator, the discriminator maintains gradient activity in the following way: The unitary constraint of the quantum discriminator forces the gradient directions of different samples to remain orthogonal (because the column vectors of the unitary matrix are orthogonal), avoiding the discriminator from producing the same output for all generated samples (i.e., the gradient convergence problem of mode collapse). The gradient weights of the current layer are dynamically adjusted by control bits in the entanglement gate (such as features from the previous layer). The expected value of the quantum discriminator output contains both classical adversarial loss (such as JS divergence) and hidden information about the entanglement of quantum states. This hybrid gradient signal allows the generator to utilize gradient guidance from both the classical data distribution and the quantum feature space.
[0055] Significant improvements can still be achieved when the quantum residual neural module is used only in either the generator or the discriminator: Quantum generator + classical discriminator: Lossless propagation of the generator's quantum gradient can mitigate the vanishing gradient effect of the discriminator. Even if the classical discriminator output saturates, the quantum generator can still obtain an effective update direction through parameter shifting rules.
[0056] Classical generator + quantum discriminator: The stable gradient signal of the quantum discriminator avoids the "overwhelming advantage" problem of the classical discriminator. Its unitarity constraint prevents the discriminator from converging prematurely and continuously provides meaningful gradients for the generator.
[0057] This application reduces the risk of overfitting by decreasing the number of parameters through quantum convolutional layers, which helps maintain gradient stability. The introduction of quantum residual neural modules enables the network to avoid the vanishing gradient problem while maintaining the entanglement and evolution of quantum states using residual connection mechanisms. Specifically, the use of entanglement gates achieves effective entanglement between qubits, enhancing the expressive power of quantum states. Entangled states provide more quantum information, helping to maintain the magnitude of gradients during training and thus reducing the possibility of gradient vanishing. Parameterized training logic gates endow the network with the ability to learn and adjust the evolution of quantum states to better adapt to training data. This parameterization method increases the network's flexibility and helps avoid gradient vanishing during training. Furthermore, qubits of adjacent feature data form chain entanglement through a sharing mechanism, constructing long-distance dependencies across modules. This structure is similar to the attention mechanism in Transformer models, allowing gradients to propagate efficiently through entangled links, rather than relying solely on layer-by-layer propagation. Therefore, this application effectively suppresses the vanishing gradient problem and reduces the waste of training resources caused by training failures by introducing quantum residual neural modules and quantum convolutional layers.
[0058] In some embodiments of this application, the training of the generator and the discriminator are performed alternately. Alternating training means that during training, instead of updating the parameters of the generator and discriminator simultaneously, the parameters of one are fixed first, the other network is trained, and then the roles are switched. This training strategy helps balance the learning progress of both, preventing one from overtaking the other too quickly. First, the generator's parameters are fixed and not updated. The discriminator attempts to distinguish between real samples (drawn from the real dataset) and generated samples (generated by the current generator). The discriminator's parameters are updated using its loss function (such as binary cross-entropy loss) to better distinguish between real and generated samples. Then, the discriminator's parameters are fixed and not updated. The generator attempts to generate samples to deceive the discriminator into misclassifying the generated samples as real samples. The generator's parameters are updated using its loss function (typically related to the discriminator's output; for example, it is desirable for the discriminator's output for generated samples to be close to 1) to make the generated samples more realistic. The above steps are repeated until a stopping condition is met, such as the number of training epochs, the stability of the quality of generated samples, or the performance of the discriminator.
[0059] Alternating training helps balance the learning progress of the generator and discriminator, preventing one from overtaking the other too quickly and causing training instability. By fixing the parameters of one, more focus can be placed on optimizing the other, thereby improving training efficiency. Alternating training also helps the network converge to a stable solution faster, even if this solution is not the global optimum.
[0060] In some embodiments of this application, the quantum convolutional layer is a quantum void convolutional layer.
[0061] Quantum dilated convolutional layers are a significant extension of quantum convolutional layers. Their core innovation lies in systematically expanding the receptive field of the convolutional kernel by introducing the hyperparameter of dilation rate. This technique inserts a fixed number of zero weights (specifically, the dilation rate *r* minus 1) between consecutive kernel elements, resulting in a regular gap sampling pattern in the originally compact kernel. Specifically, the actual receptive field is calculated as *k + (k-1)*(d-1), where *k* is the kernel size and *d* is the dilation rate. For example, with a 2×2 quantum convolutional kernel of dilation rate *r*=3, inserting two zero values between kernel elements expands the actual receptive field to 4×4, while traditional standard quantum convolutions can only maintain a 2×2 receptive field with the same kernel size. This design achieves three advantages: first, it significantly expands the feature capture range without increasing the number of learnable parameters; second, it effectively models long-range dependencies in temporal data through the gap sampling mechanism; and finally, it maintains the parameter efficiency advantage of quantum computing, avoiding a surge in computational complexity caused by expanding the receptive field.
[0062] In generators, dilated convolutions can improve the global consistency and detail richness of generated samples; in discriminators, they can enhance the joint discrimination ability of global and local features and improve the accuracy of distinguishing between real and fake samples.
[0063] Quantum spatial convolutional layers typically consist of an encoding layer, a parameter layer, and a measurement layer. The parameter layer applies a set of single-qubit and multi-qubit quantum logic gates to the encoded quantum state. Multi-qubit quantum logic gates are typically CNOT gates and parameterized rotation gates, used to generate correlated quantum states, i.e., entangled states. Single-qubit quantum logic gates are primarily parameterized rotation gates. This combination of single-qubit and multi-qubit quantum logic gates in a quantum spatial convolutional neural network is called a parameterization layer, used to extract features specific to a particular task. This parameterization layer is usually repeated multiple times to expand the feature space. The main purpose of the measurement layer is to extract a classical output vector by utilizing a mapping from the quantum state to a classical vector. Figure 3 As shown, Figure 3 This is a schematic diagram of the structure of a quantum circuit corresponding to a quantum spatial convolutional layer, provided in an embodiment of this application. The quantum circuit includes 4 qubits, each of which is sequentially gated by an H-gate, ... effect, This represents a parameterized rotation gate, where all qubits are initially in the 0 state. The parameter layer in the diagram is represented by a unitary matrix U, which represents a set of single-qubit and multi-qubit quantum logic gates.
[0064] In some embodiments of this application, the first quantum logic gate and the second quantum logic gate are of the same type. The fact that the first and second quantum logic gates are of the same type means that the two identity mapping gates are implemented using the same quantum logic gate, which simplifies the design of quantum circuits because they have the same mathematical form and operational effects. This reduces the number of gate types that the quantum chip needs to support, and also maintains the symmetry of information flow along the identity path.
[0065] In some implementations, the first and second quantum logic gates are H-gates or parametric quantum logic gates. H-gates achieve an identity mapping by transforming qubits from a deterministic state to a superposition state. Parametric quantum logic gates achieve the identity mapping by adjusting parameters. Parametric quantum logic gates can dynamically adjust parameters based on training data or optimization goals, enabling more flexible quantum operations. The role of the first and second quantum logic gates is to maintain certain properties of the feature data unchanged or to perform some simple transformation. This symmetry helps ensure the consistency and stability of the quantum circuit when processing feature data.
[0066] In some embodiments of this application, when the first quantum logic gate and the second quantum logic gate are H gates, the parameterized training logic gate and the first quantum logic gate are of different types, and the quantum circuit obtains residuals based on the evolution results of the feature data from the parameterized training logic gate.
[0067] When the first and second quantum logic gates are H-gates, the quantum circuit uses parameterized training gates to evolve feature data and obtain residuals. The parameterized training gates learn "incremental information," similar to the residual function F(x) in classical residual networks.
[0068] In some embodiments of this application, when the first quantum logic gate and the second quantum logic gate are parametric quantum logic gates, the parameterized training logic gate and the first quantum logic gate are of the same type, and the quantum circuit obtains residuals based on the evolution results of the feature data from the parameterized training logic gate, the first quantum logic gate, and the second quantum logic gate.
[0069] When the first and second quantum logic gates are parametric quantum logic gates, the quantum circuit uses the parameterized training gates, the first quantum logic gate, and the second quantum logic gate to evolve the feature data and obtain the residual. The parameterized training gates, the first quantum logic gate, and the second quantum logic gate jointly learn the "incremental information".
[0070] In some embodiments of this application, when the first quantum logic gate and the second quantum logic gate are parametric quantum logic gates, the type of the encoded logic gate and the first quantum logic gate are the same.
[0071] Different types of quantum logic gates can cause the eigenvalue distribution of the Heisenberg matrix to diverge. This means that the range of eigenvalues is very wide, from very small to very large. Eigenvalue divergence leads to exponential decay of gradients in some directions. Specifically, when the range of eigenvalues is very wide, the gradients corresponding to smaller eigenvalues will be very small, even approaching zero. This makes it difficult for optimization algorithms to update parameters in these directions, resulting in slow or even stalled training. Encoding the logic gates with the same type as the first quantum logic gate alleviates gradient vanishing. In quantum chips, different gates require different microwave pulse sequences. Switching between gate types introduces delay and crosstalk errors. Unifying the gate type allows the compiler to optimize pulse waveform reuse, reducing pulse compilation overhead and suppressing crosstalk.
[0072] For example, when both the encoding logic gate and the first quantum logic gate are RY gates, a quantum residual block can be configured as follows: Figure 4 As shown, the RY gate in the red box is the encoding logic gate. Of the other two RY gates, the one that comes first is the first quantum logic gate, and the one that comes second is the second quantum logic gate. The rotation angles of the two RY gates are obtained through training and optimization. Figure 4 The U3 gate is a parameterized training logic gate, and the entanglement gate is a CNOT gate.
[0073] See Figure 5 , Figure 5 This application provides a training device for a quantum generative adversarial network, the quantum generative adversarial network including a generator and a discriminator, the device comprising: The sample generation module is used to generate samples for random noise using a generator. The discrimination result acquisition module is used to use the discriminator to discriminate between the real sample and the output result to obtain the discrimination result; A training module is used to update 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 quantum generative adversarial network. At least one of the generator and the discriminator includes a quantum convolutional layer and a quantum residual neural module connected in sequence. The quantum residual neural module includes: a first qubit and a second qubit for encoding and evolving each feature data; a first quantum logic gate and a second quantum logic gate acting on the first qubit for performing an identity mapping operation on the feature data; and a third quantum logic gate acting on the second qubit and entangled with the first qubit between the first and second quantum logic gates. The third quantum logic gate includes an encoding module for encoding the feature data and parameterized training logic gates located before and after the encoding module for implementing residuals. The encoding module includes an encoding logic gate and entanglement gates located before and after the encoding logic gates, and the entanglement gates implement entanglement between 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, and the feature data is obtained based on the quantum convolutional layer.
[0074] The specific functions and effects of the training device for the quantum generative adversarial network described above can be explained by referring to other embodiments of this application, and will not be repeated here. Each sub-circuit in the training device for the quantum generative adversarial network can be implemented entirely or partially through software, hardware, or a combination thereof. Each sub-circuit can be embedded in or independent of the processor in a computer device in hardware form, or it can be stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each of the above sub-circuits.
[0075] Please see Figure 6 This application also provides a computer device, including a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the training method for the quantum generative adversarial network in any of the above embodiments. Please refer to [link to relevant documentation]. Figure 6 The computer device can be a classical computer or a quantum computer.
[0076] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a computer, causes the computer to perform the training method for the quantum generative adversarial network in any of the above embodiments.
[0077] This application also provides a computer program product containing instructions that, when executed by a computer, cause the computer to perform the training method for the quantum generative adversarial network in any of the above embodiments.
[0078] It is understood that in the various embodiments of this application, the sequence number of each process does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not limit the implementation process of the embodiments of this application in any way.
[0079] It is understood that the various implementation methods described in this application can be implemented individually or in combination, and the implementation methods in this application are not limited in this respect.
[0080] Unless otherwise stated, all technical and scientific terms used in the embodiments of this application have the same meaning as commonly understood by one of ordinary skill in the art. The terminology used in this application is for the purpose of describing particular embodiments only and is not intended to limit the scope of this application. The term "and / or" as used in this application includes any and all combinations of one or more of the associated listed items. The singular forms "a," "the," and "the" as used in the embodiments of this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise.
[0081] It is understood that the processor in the embodiments of this application can be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method embodiments can be completed by the integrated logic circuits in the processor's hardware or by instructions in software form. The processor can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software sub-circuits in the decoding processor. The software sub-circuits can be located in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. This storage medium is located in memory, and the processor reads the information in the memory and, in conjunction with its hardware, completes the steps of the above method.
[0082] It is understood that the memory in the embodiments of this application may be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. Specifically, non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory may be random access memory (RAM). It should be noted that the memory in the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0083] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0084] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the aforementioned method implementations, and will not be repeated here.
[0085] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0086] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment, depending on actual needs.
[0087] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0088] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
Claims
1. A training method for quantum generative adversarial networks, characterized in that, The quantum generative adversarial network includes a generator and a discriminator, and the method includes: Using a generator, generated samples are obtained for random noise; The discriminator is used to distinguish between real samples and generated samples to obtain a discrimination result; Based on the discrimination result, the loss function of the generator, and the loss function of the discriminator, the parameters of the generator and the discriminator are updated to obtain the trained quantum generative adversarial network. At least one of the generator and the discriminator includes a quantum convolutional layer and a quantum residual neural module connected in sequence. The quantum residual neural module includes: a first qubit and a second qubit for encoding and evolving each feature data; a first quantum logic gate and a second quantum logic gate acting on the first qubit for performing an identity mapping operation on the feature data; and a third quantum logic gate acting on the second qubit and entangled with the first qubit between the first and second quantum logic gates. The third quantum logic gate includes an encoding module for encoding the feature data and parameterized training logic gates located before and after the encoding module for implementing residuals. The encoding module includes an encoding logic gate and entanglement gates located before and after the encoding logic gates, and the entanglement gates implement entanglement between 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, and the feature data is obtained based on the quantum convolutional layer.
2. The method as described in claim 1, characterized in that, The training of the generator and the training of the discriminator are carried out alternately.
3. The method as described in claim 1, characterized in that, The quantum convolutional layer is a quantum void convolutional layer.
4. The method as described in claim 1, characterized in that, The first quantum logic gate and the second quantum logic gate are quantum logic gates of the same type.
5. The method as described in claim 4, characterized in that, The first and second quantum logic gates are H-gates or parameterized quantum logic gates.
6. The method as described in claim 5, characterized in that, When the first and second quantum logic gates are H-gates, the parameterized training logic gates and the first quantum logic gates are of different types, and the quantum circuit obtains residuals based on the evolution results of the feature data from the parameterized training logic gates.
7. The method as described in claim 5, characterized in that, When the first quantum logic gate and the second quantum logic gate are parametric quantum logic gates, the parameterized training logic gate and the first quantum logic gate are of the same type, and the quantum circuit obtains the residual based on the evolution results of the feature data by the parameterized training logic gate, the first quantum logic gate, and the second quantum logic gate.
8. A training device for a quantum generative adversarial network, characterized in that, The quantum generative adversarial network includes a generator and a discriminator, and the device includes: The sample generation module is used to generate samples for random noise using a generator. The discrimination result acquisition module is used to use the discriminator to discriminate between the real sample and the output result to obtain the discrimination result; A training module is used to update 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 quantum generative adversarial network. At least one of the generator and the discriminator includes a quantum convolutional layer and a quantum residual neural module connected in sequence. The quantum residual neural module includes: a first qubit and a second qubit for encoding and evolving each feature data; a first quantum logic gate and a second quantum logic gate acting on the first qubit for performing an identity mapping operation on the feature data; and a third quantum logic gate acting on the second qubit and entangled with the first qubit between the first and second quantum logic gates. The third quantum logic gate includes an encoding module for encoding the feature data and parameterized training logic gates located before and after the encoding module for implementing residuals. The encoding module includes an encoding logic gate and entanglement gates located before and after the encoding logic gates, and the entanglement gates implement entanglement between 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, and the feature data is obtained based on the quantum convolutional layer.
9. A computer device comprising a memory and a processor, the memory storing a computer program, the processor executing the computer program to implement the training method of the quantum generative adversarial network of any one of claims 1-7.
10. A computer-readable storage medium having a computer program stored thereon, which, when executed by a computer, causes the computer to perform the training method of the quantum generative adversarial network according to any one of claims 1-7.