Quantum generative adversarial network training method and system based on parameterized quantum circuit
By using parameterized quantum circuits and fully connected neural networks in quantum generation adversarial networks, the alternating gradient update of generator and discriminator parameters is optimized, the gradient disappearance problem under the influence of noise is solved, the model performance and stability are improved, and it is suitable for Medium-sized quantum computer.
Patent Information
- Application Number
- CN202411093731.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-09
- Publication Date
- 2024-11-22
AI Technical Summary
When the number of quantum bits and quantum gates increases, the model performance is affected by noise, resulting in gradient disappearance, making it difficult to effectively train and deploy on quantum computer devices of medium noise scale.
The quantum generation adversarial network training method based on parameterized quantum circuits is adopted. By converting random noise into a parametric single-layer quantum circuit in the data encoding stage, combining with a fully connected neural network, the generator and discriminator parameters are optimized. Alternate gradient update process, using classic computing resources to perform K-step discriminator updates to reduce noise impact.
It improves the performance of the quantum generation adversarial network, avoids pattern collapse, has better generation effect and stability, and is suitable for current noise-containing medium-sized quantum computers without additional quantum computing resource overhead.
Smart Images

Figure CN119005257A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of quantum computing technology, and in particular to a quantum generative adversarial network training method and system based on parameterized quantum circuits. Background Art
[0002] With the rapid development of computer science and information technology, people are increasingly demanding to improve computing power and solve complex problems. Traditional approximate computing has reached a performance bottleneck, and traditional optimization methods are also facing challenges such as difficulty in solving high-dimensional complex problems. Quantum computing, as a new computing model with great potential, has attracted widespread attention. Quantum machine learning is the application of machine learning methods to quantum computing tasks such as classification, clustering, and pattern recognition. In traditional computer learning, data is usually represented in the form of vectors or matrices, which require large-scale collection and labeling to train the model. In quantum computing, data can be represented as the state of one or more quantum bits, but due to experimental conditions and complexity, it is very difficult to obtain large-scale labeled real data sets. At present, a GAN model is trained to generate virtual data sets with similar distribution characteristics. In the existing research on quantum generative adversarial networks, the model structure is mainly designed based on quantum computing theory, and the performance of quantum generative adversarial networks is improved by increasing the depth of the structure or using additional auxiliary quantum bits. For some target data sets used in experiments, this method of changing model performance only through structural design has room for further optimization. More importantly, when quantum generative adversarial networks are deployed on medium-noise quantum computer devices, the impact of noise on the model must be taken into account. This impact increases with the number of quantum bits and quantum gates used in the model. Noise can cause the quantum generative model to experience gradient vanishing during parameter optimization. Summary of the invention
[0003] To this end, the present invention provides a quantum generative adversarial network training method and system based on parameterized quantum circuits to solve the problem that the performance of the current quantum generative adversarial network is affected by the increase in the number of quantum bits and quantum gates. The performance of the quantum generative adversarial network is improved by optimizing the alternating gradient update process between the generator and discriminator parameters to meet the needs of application scenarios in quantum computing tasks.
[0004] According to the design scheme provided by the present invention, on the one hand, a quantum generative adversarial network training method based on parameterized quantum circuits is provided, comprising:
[0005] Constructing a quantum generative adversarial network, the quantum generative adversarial network includes a generator and a discriminator, the generator uses a parameterized single-layer quantum circuit that converts random noise into a noise input quantum state in a data encoding stage, and the discriminator uses a fully connected neural network;
[0006] The quantum generative adversarial network is trained based on real data and noisy data, and K-step discriminator updates are performed in each single step of the generator update during the training process, where the K-step discriminator updates are performed on classical computing resources and K is a natural number.
[0007] As a quantum generative adversarial network training method based on parameterized quantum circuits of the present invention, further, the fully connected neural network adopts multiple hidden layers, and each hidden layer adopts a different number of neurons.
[0008] As a quantum generative adversarial network training method based on parameterized quantum circuits of the present invention, further, the quantum generative adversarial network is trained based on real data and noise data, comprising:
[0009] Using the noise data and obtaining generated data through the generator, determining a first loss function of the discriminator relative to the generated data based on the generated data and the discriminator;
[0010] A second loss function of the discriminator relative to the real data is determined using the real data and the discriminator to update the generator parameters based on the first loss function during the training cycle, and to update the discriminator parameters based on the first loss function and the second loss function.
[0011] As a quantum generative adversarial network training method based on parameterized quantum circuits of the present invention, further, the discriminator updating process includes:
[0012] Set up the loop variable and initialize it;
[0013] Determine whether the loop variable is equal to K. If not, the loop executes the following process:
[0014] Sampling from real data and inputting the sampled data into the discriminator, obtaining the first loss of the discriminator based on the real data; sampling from noise data and inputting the sampled data into the generator, using the generator to obtain generated data, and obtaining the second loss of the discriminator based on the generated data;
[0015] Based on the first loss and the second loss, the discriminator parameters are updated using the Adam optimization algorithm, and the loop variable is increased by 1.
[0016] As a quantum generative adversarial network training method based on parameterized quantum circuits of the present invention, further, the discriminator parameter update process is expressed as: Among them, θ D are the discriminator parameters, is the expected value of the real sample, D(x) is the probability that the discriminator judges that the input data x is the real data type, G(x) is the generated data obtained by the generator based on the noise input, To generate sample expectations.
[0017] As a quantum generative adversarial network training method based on parameterized quantum circuits of the present invention, further, the generator update process includes:
[0018] Sample from the noise data and input the sampled data into the generator, use the generator to obtain the generated data, obtain the generator loss based on the generated data, and update the generator parameters based on the generator loss and using the Adam optimization algorithm.
[0019] On the other hand, the present invention also provides a quantum generative adversarial network training system based on parameterized quantum circuits, comprising: a network setting module and a network training module, wherein:
[0020] A network setting module, used to construct a quantum generative adversarial network, wherein the quantum generative adversarial network includes a generator and a discriminator, wherein the generator uses a parameterized single-layer quantum circuit that converts random noise into a noise input quantum state in a data encoding stage, and the discriminator uses a fully connected neural network;
[0021] The network training module is used to train the quantum generative adversarial network based on real data and noise data, and perform K-step discriminator updates in each single step of the generator update during the training process, where the K-step discriminator updates are performed on classical computing resources and K is a natural number.
[0022] In another aspect, the present invention further provides a method for generating sample data in a quantum computing task, comprising:
[0023] Obtain target data for quantum computing tasks;
[0024] The target data is used as real data, and the quantum generative adversarial network is trained using the above-mentioned quantum generative adversarial network training method based on parameterized quantum circuits, and the trained generator is used as the target model;
[0025] Use the target model to obtain sample data required for quantum computing tasks.
[0026] Beneficial effects of the present invention:
[0027] The present invention optimizes the gradient update of alternating between the generator parameters and the discriminator parameters in the adversarial training of quantum generative adversarial networks, and at the same time enhances the generation capability of the generator at the cost of increasing the consumption of classical computing resources, and does not require additional quantum computing resource overhead, which can improve the performance of quantum generative adversarial networks. Further simulation results show that compared with the existing QGAN, this solution has better generation effect and higher stability, can be applied to the current noisy medium-sized quantum computers, and can effectively avoid mode collapse during adversarial training, and has good application prospects. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 It is a schematic diagram of the training process of a quantum generative adversarial network based on a parameterized quantum circuit in an embodiment;
[0029] Figure 2 This is a schematic diagram of the quantum circuit used by the generator in the embodiment;
[0030] Figure 3 It is a comparison diagram of the generation effect of the existing QGAN in the embodiment and the Unrolled QGAN in the solution of this case;
[0031] Figure 4 It is a schematic diagram of the KL divergence change curve in the embodiment;
[0032] Figure 5 Schematic diagram of the performance of QGAN in the embodiment as the K value changes. DETAILED DESCRIPTION
[0033] In order to make the purpose, technical solutions and advantages of the present invention clearer and more understandable, the present invention is further described in detail below in conjunction with the accompanying drawings and technical solutions.
[0034] Embodiments of the present invention, see Figure 1 As shown, a quantum generative adversarial network training method based on parameterized quantum circuits is provided, comprising:
[0035] S101. Construct a quantum generative adversarial network, wherein the quantum generative adversarial network includes a generator and a discriminator. The generator adopts a parameterized single-layer quantum circuit that converts random noise into a noise input quantum state in a data encoding stage, and the discriminator adopts a fully connected neural network.
[0036] Among them, the fully connected neural network can use multiple hidden layers, for example, 3 hidden layers can be used, and the number of neurons in each layer can be 64, 16, and 1 respectively. The structure of the generator used is as follows Figure 2As shown in the quantum circuit in the figure, the quantum circuit first converts the random noise source into a quantum state in the data encoding stage as the noise input of the generator. The dotted boxes are all single-layer quantum circuits, which can be repeated in the experiment; RY(z) is the data encoding layer, RX(θ), RZ(β) and All of them contain variable parameters. On the basis of appropriately saving quantum computing resources, the generator uses 3 layers of quantum circuits.
[0037] S102. The quantum generative adversarial network is trained based on real data and noise data, and a K-step discriminator update is performed in each single step of the generator update during the training process, wherein the K-step discriminator update is performed on classical computing resources, and K is a natural number.
[0038] Specifically, the quantum generative adversarial network is trained based on real data and noise data, and can be designed to include:
[0039] Using the noise data and obtaining generated data through the generator, determining a first loss function of the discriminator relative to the generated data based on the generated data and the discriminator;
[0040] A second loss function of the discriminator relative to the real data is determined using the real data and the discriminator to update the generator parameters based on the first loss function during the training cycle, and to update the discriminator parameters based on the first loss function and the second loss function.
[0041] Among them, the discriminator update process may include:
[0042] Set up the loop variable and initialize it;
[0043] Determine whether the loop variable is equal to K. If not, the loop executes the following process:
[0044] Sampling from real data and inputting the sampled data into the discriminator, obtaining the first loss of the discriminator based on the real data; sampling from noise data and inputting the sampled data into the generator, using the generator to obtain generated data, and obtaining the second loss of the discriminator based on the generated data;
[0045] Based on the first loss and the second loss, the discriminator parameters are updated using the Adam optimization algorithm, and the loop variable is increased by 1.
[0046] The generator update process may include:
[0047] Sample from the noise data and input the sampled data into the generator, use the generator to obtain the generated data, obtain the generator loss based on the generated data, and update the generator parameters based on the generator loss and using the Adam optimization algorithm.
[0048] The basics of the quantum generative adversarial network training algorithm can be shown in Algorithm 1:
[0049]
[0050]
[0051] Further, based on the above method, an embodiment of the present invention also provides a quantum generative adversarial network training system based on parameterized quantum circuits, comprising: a network setting module and a network training module, wherein:
[0052] A network setting module, used to construct a quantum generative adversarial network, wherein the quantum generative adversarial network includes a generator and a discriminator, wherein the generator uses a parameterized single-layer quantum circuit that converts random noise into a noise input quantum state in a data encoding stage, and the discriminator uses a fully connected neural network;
[0053] The network training module is used to train the quantum generative adversarial network based on real data and noise data, and perform K-step discriminator updates in each single step of the generator update during the training process, where the K-step discriminator updates are performed on classical computing resources and K is a natural number.
[0054] Furthermore, the present invention also provides a method for generating sample data in a quantum computing task, comprising:
[0055] Obtain target data for quantum computing tasks;
[0056] The target data is used as real data, and the quantum generative adversarial network is trained using the above-mentioned quantum generative adversarial network training method based on parameterized quantum circuits, and the trained generator is used as the target model;
[0057] Use the target model to obtain sample data required for quantum computing tasks.
[0058] In order to verify the effectiveness of this solution, the following is a further explanation based on simulation test data:
[0059] In order to measure the performance of the existing QGAN and the Unrolled QGAN in this case, two models are used to generate Gaussian curves, and KL divergence is used as a parameter to measure the performance of the two, that is, 3000 sets of Gaussian curves are generated using the trained QGAN model, the average of the generated 3000 sets of data is calculated to obtain the fitting curve, and the KL divergence between the training data and the average of the generated 3000 sets of data is calculated. The smaller the KL divergence value, the better the performance of QGAN. In the experiment, the Gaussian curves generated by QGAN and Unrolled QGAN have 64 sampling points, which means that the generation task can be completed using 6 quantum bits, but without adding auxiliary bits, the quantum circuits all perform unitary transformations (linear transformations), and an additional quantum bit needs to be introduced as an auxiliary bit, thereby introducing nonlinear operations. Figure 2 The quantum circuits are all set to 7 bits, and the repeatable variable parameter layer is set to L=3.
[0060] Quantum circuit simulation and construction are implemented in the library Pennylane. The Adam optimizer is used, the batch size is 1, the learning rate of the discriminator is 0.0001, and the learning rate of the generator is 0.02. The loss function is the cross entropy loss. There are 3000 sets of training data in total, the number of training epochs = 2500 rounds, and the hyperparameter K (Unrolled step size) can be selected in the interval [1,10].
[0061] In this solution, the model after introducing the training techniques of this solution to QGAN is denoted as Unrolled QGAN. QGAN and Unrolled QGAN use the same discriminator and generator.
[0062] Figure 3 The results of Gaussian curve generation based on QGAN and Unrolled QGAN. After training, the generators of QGAN and Unrolled QGAN were sampled 3000 times respectively. Both QGAN and Unrolled QGAN approximately generated Gaussian curves and completed the generation task. Figure 3 The Gaussian curve generated by QGAN has a KL divergence of 0.1062 between the generated data and the original data. Figure 3 Gaussian curve generated by Unrolled QGAN after the Unrolled training technique is introduced in , where the hyperparameter K=5 and the KL divergence between the generated and original data is 0.0154.
[0063] from Figure 3 From the generation results of QGAN and Unrolled QGAN, it can be seen that QGAN is less effective in generating Gaussian curves. After training, the generator of QGAN can only generate data on both sides of the Gaussian curve more appropriately, and cannot generate a complete Gaussian curve well. However, for these data, the judgment output of the discriminator will be a value close to 1, that is, it is believed that these data come from the real data set. The discriminator cannot guide the generator to learn the distribution of real data. In contrast, the data generated by Unrolled QGAN is almost the same as the target Gaussian curve. The results of the generated data and the KL divergence both show that the performance of Unrolled QGAN is better than that of QGAN. Compared with QGAN, Unrolled QGAN requires additional computing resources to optimize the discriminator to enhance the generator's capabilities. The discriminator in Unrolled QGAN is a classical neural network, so additional optimization of the discriminator requires classical computing resources. In terms of the consumption of quantum computing resources, UnrolledQGAN and QGAN are the same.
[0064] Figure 4 The KL divergence between the generated data and the target data during training is shown. During adversarial training, the optimization task is completed by alternately updating the parameters of the discriminator and the generator. After each update of the generator parameters, the output of the generator is sampled 100 times and the KL divergence between the sampled data and the target data is calculated. Both QGAN and Unrolled QGAN based on continuous distribution belong to the generative model of implicit probability density function. They cannot directly learn the probability distribution of target data and only have the ability to generate data samples. Therefore, the KL divergence between the generated data and the target data fluctuates during the training process and continues until the end of training. After 1000 rounds of training, the KL divergence between the generated data and the target data of Unrolled QGAN is closer to 0 than the KL divergence between the generated data and the target data of QGAN. This shows that Unrolled QGAN is easier to converge than QGAN to a certain extent.
[0065] Table 1. Standard deviations of target distribution and generated distribution
[0066]
[0067] The standard deviation of the pseudo data generated by QGAN and the standard deviation of the pseudo data generated by Unrolled QGAN are shown in Table 1. The standard deviation is used as an evaluation indicator to compare the generation capabilities of QGAN and Unrolled QGAN because the standard deviation can reflect the dispersion of data. In the Gaussian curve generation task, the standard deviation of the pseudo data generated by QGAN and Unrolled QGAN is close to the standard deviation of the target data distribution, indicating that both generators have successfully learned the target distribution characteristics. However, the standard deviation of the pseudo data set generated by Unrolled QGAN is closer to the standard deviation of the real data distribution, and the error between the two is only 0.0003, indicating that the performance of Unrolled QGAN is better than that of QGAN.
[0068] The training time of the model with the Unrolled training technique will increase with the increase of K value, because the Unrolled training technique improves the performance of QGAN at the expense of some classical calculations. Figure 5The KL divergence curve for evaluating the performance of UnrolledQGAN with the hyperparameter K value is given. When K = 0, it is the standard QGAN training step. In general, as the K value increases, the performance of Unrolled QGAN is gradually getting better, that is, more Unrolled training can enhance the performance of QGAN. When K = 6 and K = 9, the performance of Unrolled QGAN is basically optimal. On the basis of being able to complete the QGAN generation task and considering the consumed computing resources, K = 6 can be selected.
[0069] Based on the above experimental results, it is shown that this scheme has better generation effect and higher stability, does not require additional quantum computing resource overhead, can be applied to current noisy medium-sized quantum computers, and can effectively avoid mode collapse during adversarial training.
[0070] Unless otherwise specifically stated, the relative steps, numerical expressions and values of the components and steps set forth in these embodiments do not limit the scope of the present invention.
[0071] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the system disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0072] The units and method steps of each example described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. A person of ordinary skill in the art may use different methods to implement the described functions for each specific application, but such implementation is not considered to be beyond the scope of the present invention.
[0073] Those skilled in the art will appreciate that all or part of the steps in the above method can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium, such as a read-only memory, a disk or an optical disk. Optionally, all or part of the steps in the above embodiment can also be implemented using one or more integrated circuits, and accordingly, each module / unit in the above embodiment can be implemented in the form of hardware or in the form of software function modules. The present invention is not limited to any specific form of combination of hardware and software.
[0074] Finally, it should be noted that the above-described embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The protection scope of the present invention is not limited thereto. Although the present invention is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed by the present invention, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims
1. A quantum generative adversarial network training method based on parameterized quantum circuits, characterized in that: Include: Constructing a quantum generative adversarial network, the quantum generative adversarial network includes a generator and a discriminator, the generator uses a parameterized single-layer quantum circuit that converts random noise into a noise input quantum state in a data encoding stage, and the discriminator uses a fully connected neural network; The quantum generative adversarial network is trained based on real data and noisy data, and K-step discriminator updates are performed in each single step of the generator update during the training process, where the K-step discriminator updates are performed on classical computing resources and K is a natural number.
2. The quantum generative adversarial network training method based on parameterized quantum circuits according to claim 1 is characterized in that: The fully connected neural network uses multiple hidden layers, and each hidden layer uses a different number of neurons.
3. The quantum generative adversarial network training method based on parameterized quantum circuits according to claim 1 is characterized in that: Training quantum generative adversarial networks based on real data and noise data, including: Using the noise data and obtaining generated data through the generator, determining a first loss function of the discriminator relative to the generated data based on the generated data and the discriminator; A second loss function of the discriminator relative to the real data is determined using the real data and the discriminator to update the generator parameters based on the first loss function during the training cycle, and to update the discriminator parameters based on the first loss function and the second loss function.
4. The quantum generative adversarial network training method based on parameterized quantum circuits according to claim 1 or 3, characterized in that: The discriminator update process includes: Set up the loop variable and initialize it; Determine whether the loop variable is equal to K. If not, the loop executes the following process: Sampling from real data and inputting the sampled data into the discriminator, obtaining the first loss of the discriminator based on the real data; Sampling from the noise data and inputting the sampled data into the generator, using the generator to obtain generated data, and obtaining the second loss of the discriminator based on the generated data; Based on the first loss and the second loss, the discriminator parameters are updated using the Adam optimization algorithm, and the loop variable is increased by 1.
5. The quantum generative adversarial network training method based on parameterized quantum circuits according to claim 4 is characterized in that: The discriminator parameter update process is expressed as: Among them, θ D are the discriminator parameters, is the expected value of the real sample, D(x) is the probability that the discriminator judges that the input data x is the real data type, G(x) is the generated data obtained by the generator based on the noise input, To generate sample expectations.
6. The quantum generative adversarial network training method based on parameterized quantum circuits according to claim 1 or 3, characterized in that: The generator update process includes: Sample from the noise data and input the sampled data into the generator, use the generator to obtain the generated data, obtain the generator loss based on the generated data, and update the generator parameters based on the generator loss and using the Adam optimization algorithm.
7. A quantum generative adversarial network training system based on parameterized quantum circuits, characterized in that: Contains: network setting module and network training module, among which, A network setting module, used to construct a quantum generative adversarial network, wherein the quantum generative adversarial network includes a generator and a discriminator, wherein the generator uses a parameterized single-layer quantum circuit that converts random noise into a noise input quantum state in a data encoding stage, and the discriminator uses a fully connected neural network; The network training module is used to train the quantum generative adversarial network based on real data and noise data, and perform K-step discriminator updates in each single step of the generator update during the training process, where the K-step discriminator updates are performed on classical computing resources and K is a natural number.
8. A method for generating sample data in a quantum computing task, characterized in that: Contains the following: Obtain target data for quantum computing tasks; Taking the target data as real data, training the quantum generative adversarial network using the quantum generative adversarial network training method based on parameterized quantum circuits as described in claim 1, and taking the trained generator as the target model; Use the target model to obtain sample data required for quantum computing tasks.
9. An electronic device, characterized in that: include: at least one processor, and a memory coupled to the at least one processor; The memory stores a computer program, and the computer program can be executed by the at least one processor to implement the method according to any one of claims 1 to 6.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed, the method according to any one of claims 1 to 6 can be implemented.
Citation Information
Cited By
Generative adversarial network design method based on quantum coupling
CN120031075A
Power system renewable energy scene generation method based on quantum generative adversarial network
CN120542247A
