Face Image Generation Method Based on Hybrid Quantum-Classical Generative Adversarial Neural Network
By mixing quantum classical generation adversarial neural networks, using quantum generative neural networks to generate face image feature data, and combining classic discriminant network training, the problem of insufficient face image generation efficiency in the existing technology is solved, and more efficient face image generation is achieved.
Patent Information
- Application Number
- CN202410357253.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-27
- Publication Date
- 2025-07-18
- Estimated Expiration
- 2044-03-27
AI Technical Summary
In the prior art, face image generation is mainly processed by classic machine learning methods, and has not yet involved quantum machine learning, resulting in insufficient image generation efficiency and feature extraction speed.
A hybrid quantum classical generation adversarial neural network is used to load classic random noise into quantum states, and a quantum generation neural network is used to generate fake face image feature data, and a classic discriminant neural network is trained in combination with classic discriminant neural network to optimize the loss function update parameters, so that the quantum generation neural network can generate facial image feature data that is difficult to be judged as fake.
Quantum generation neural networks are better than classical networks in terms of global feature extraction and convergence speed in face images, and reduce the demand for real quantum computer hardware resources, achieving more efficient face image generation.
Smart Images

Figure CN118279953B_ABST
Abstract
Description
Background Art
[0002] Image generation tasks play a crucial role in the field of computer vision today. With the rapid development of artificial intelligence technology, image generation has become a key enabling technology for many practical application scenarios, such as autonomous driving, robot vision, virtual reality, intelligent security, etc. Image generation tasks can transform computer vision algorithms from passively processing and analyzing images to actively creating and generating images, greatly enhancing the capabilities and practicality of computer vision systems. At the same time, image generation tasks can also promote the cross-integration between different disciplines, such as computer vision, graphics, deep learning, etc., and drive the common development and progress of these disciplines. Therefore, image generation tasks for different images, such as face image generation, are playing an increasingly important role in the field of computer vision today and have inestimable significance and value for future technological development and social progress. Currently, the generation of face images is mainly processed through classical machine learning, and the implementation of face image generation based on quantum machine learning has not been involved yet. Summary of the Invention
[0003] The technical problem to be solved by the present invention is to provide a face image generation method based on a hybrid quantum-classical generative adversarial neural network in view of the deficiencies of the prior art, as follows:
[0004] 1) In a first aspect, the present invention provides a face image generation method based on a hybrid quantum-classical generative adversarial neural network, and the specific technical solution is as follows:
[0005] S1. Load classical random noise as a quantum state;
[0006] S2. Use a quantum generative neural network to operate on the quantum state to generate fake face image feature data, and the dimension of the fake face image feature data is the same as that of the downsampled real face image data;
[0007] S3. Input the fake face image feature data into a classical discriminative neural network to obtain a first prediction result, and input the downsampled real face image data into the classical discriminative neural network to obtain a second prediction result;
[0008] S4. Combine the first prediction result and the second prediction result into a first loss function for training the classical discriminative neural network, and update the parameters of the classical discriminative neural network according to the first loss function;
[0009] S5. After the number of times of updating the parameters of the classical discriminant neural network reaches a preset number threshold, input the false face image feature data into the current classical discriminant neural network to obtain a prediction result. According to the prediction result, construct a second loss function for training the quantum generation neural network, and update the parameters of the quantum generation neural network according to the second loss function, so that the current classical discriminant neural network discriminates the false face image feature data as true;
[0010] S6. Return to execute S1 until the latest obtained classical discriminant neural network cannot determine whether it is false face image feature data;
[0011] S7. Use the latest obtained quantum generation neural network to generate face image feature data.
[0012] The beneficial effects of a face image generation method based on a hybrid quantum-classical generative adversarial neural network provided by the present invention are as follows:
[0013] Due to the powerful parallelism and non-local characteristics of the quantum generation neural network, the latest obtained quantum generation neural network in the present invention is superior to the classical generative adversarial neural network in both the extraction of global features of face images and the convergence speed, and is simpler than the classical generative adversarial neural network in the design of the quantum generation neural network and the adjustment of hyperparameters. And the present invention uses a classical discriminant neural network to perform the discrimination task, and only uses the latest obtained quantum generation neural network to realize the generation of face image feature data, thereby reducing the hardware resource requirements for real quantum computers.
[0014] On the basis of the above solution, a face image generation method based on a hybrid quantum-classical generative adversarial neural network of the present invention can also be improved as follows.
[0015] Further, loading the classical random noise into a quantum state includes: loading the classical random noise into a quantum state by means of angle encoding.
[0016] Further, before updating the parameters of the quantum generation neural network according to the second loss function, it further includes: fixing the parameters of the current classical discriminant neural network.
[0017] Further, the process of obtaining the dimension-reduced real face image data includes:
[0018] According to the number of qubits used by the quantum generation neural network, perform auto-encoding on the real face image data to obtain the dimension-reduced real face image data.
[0019] 2) In the second aspect, the present invention also provides a face image generation system based on a hybrid quantum-classical generative adversarial neural network. The specific technical solution is as follows:
[0020] It includes a random noise quantum state encoding module, a training module, and a face image feature data generation module;
[0021] The random noise quantum state encoding module is used to: load classical random noise as a quantum state;
[0022] The training module is used to: operate on the quantum state using a quantum generative neural network to generate fake face image feature data, where the dimension of the fake face image feature data is the same as that of the downsampled real face image data; input the fake face image feature data into a classical discriminative neural network to obtain a first prediction result, and input the downsampled real face image data into the classical discriminative neural network to obtain a second prediction result; combine the first prediction result and the second prediction result into a first loss function for training the classical discriminative neural network, and update the parameters of the classical discriminative neural network according to the first loss function; when the number of times of updating the parameters of the classical discriminative neural network reaches a preset number threshold, input the fake face image feature data into the current classical discriminative neural network to obtain a prediction result, and according to the prediction result, construct a second loss function for training the quantum generative neural network, and update the parameters of the quantum generative neural network according to the second loss function, so that the current classical discriminative neural network discriminates the fake face image feature data as real, and then recall the random noise quantum state encoding module until the latest obtained classical discriminative neural network cannot determine whether it is fake face image feature data;
[0023] The face image feature data generation module is used to: generate face image feature data using the latest obtained quantum generative neural network.
[0024] On the basis of the above solution, a face image generation system based on a hybrid quantum-classical generative adversarial neural network of the present invention can also be improved as follows.
[0025] Further, the random noise quantum state encoding module is specifically used to: load classical random noise as a quantum state by means of angle encoding.
[0026] Further, the training module is also specifically used to: fix the parameters of the current classical discriminative neural network before updating the parameters of the quantum generative neural network according to the second loss function.
[0027] Further, it further includes a real face image data preprocessing module, and the real face image data preprocessing module is used to: perform autoencoding on the real face image data according to the number of qubits used by the quantum generative neural network to obtain the downsampled real face image data.
[0028] 3) Thirdly, the present invention also provides a computer device, which includes a processor coupled to a memory. At least one computer program is stored in the memory and is loaded and executed by the processor to enable the computer device to implement any one of the above-mentioned face image generation methods based on a hybrid quantum-classical generative adversarial neural network.
[0029] 4) Fourthly, the present invention also provides a computer-readable storage medium in which at least one computer program is stored. The at least one computer program is loaded and executed by a processor to enable a computer to implement any one of the above-mentioned face image generation methods based on a hybrid quantum-classical generative adversarial neural network.
[0030] It should be noted that for the beneficial effects obtained by the technical solutions and corresponding possible implementation manners of the second to fourth aspects of the present invention, reference may be made to the above-mentioned technical effects of the first aspect and its corresponding possible implementation manners, which will not be elaborated herein. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Other features, objects, and advantages of the present invention will become more apparent by reading the following detailed description of non-limiting embodiments with reference to the accompanying drawings:
[0032] Figure 1 It is a schematic flowchart of a face image generation method based on a hybrid quantum-classical generative adversarial neural network according to an embodiment of the present invention;
[0033] Figure 2 It is a quantum circuit for loading classical random noise into a quantum state;
[0034] Figure 3 It is the network architecture of a hybrid quantum-classical generative adversarial neural network;
[0035] Figure 4 It is the network structure of a basic building block of a quantum generative neural network;
[0036] Figure 5 It is the network structure of a quantum generative neural network;
[0037] Figure 6 It is the network structure of a classical discriminative neural network;
[0038] Figure 7 It is a schematic structural diagram of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0039] To make the objectives, technical solutions, and advantages of the present invention clearer, the following will further describe the embodiments of the present invention in detail with reference to the accompanying drawings.
[0040] AsFigure 1 As shown in Figure 1 , a face image generation method based on a hybrid quantum-classical generative adversarial neural network according to an embodiment of the present invention includes the following steps:
[0041] 1) On the first hand, the present invention provides a face image generation method, and the specific technical solution is as follows:
[0042] S1. Load classical random noise into a quantum state. By means of angle encoding, load classical random noise into a quantum state.
[0043] Among them, the process of obtaining classical random noise is: randomly take 32 numbers in the standard normal distribution, denoted as r = [r1...r 32 , and take r as classical random noise.
[0044] Among them, the process of loading classical random noise into a quantum state by means of angle encoding is as follows:
[0045] For each element r1...r in classical random noise r 32 take the arctangent, that is, through the formula θ i = arctan(r i ), obtain the rotation angle of the quantum gate. Note that here r i represents the i-th element among the 32 classical random noises taken, θ i represents the rotation angle of the corresponding quantum gate, i represents the serial number of classical random noise, i is a positive integer, and the value range is 1 to 32. After obtaining the rotation angle of the quantum gate, through R y (θ) and R x (θ) rotate the quantum gate to load classical random noise onto the amplitude of the quantum state. Here, 16 qubits are used, and the specific quantum circuit is as Figure 2 shown.
[0046] S2. Use the quantum generative neural network to operate on the quantum state to generate fake face image feature data, and the dimension of the fake face image feature data is the same as the dimension of the reduced real face image data;
[0047] Among them, the process of obtaining the reduced real face image data includes:
[0048] According to the number of qubits used by the quantum generative neural network, perform auto-encoding on the real face image data to obtain the reduced real face image data.
[0049] Download the CelebA real face image dataset. The real face image dataset includes multiple real face image data. Convert the pixel channels of the real face image data in the real face image dataset into one channel by the averaging method, and reduce the 178×218-dimensional real face image data to 16 dimensions by the autoencoder method. At this time, the dimension of the reduced real face image data is 16 dimensions.
[0050] S3. Input the fake face image feature data into the classical discriminant neural network to obtain the first prediction result, and input the reduced real face image data into the classical discriminant neural network to obtain the second prediction result.
[0051] The hybrid quantum-classical generative adversarial neural network includes a quantum generative neural network and a classical discriminant neural network, and the overall architecture is as Figure 3 shown. Figure 3 In it, DNN represents the classical discriminant neural network, and QGNN represents the quantum generative neural network. The quantum generative neural network operates on the quantum state loaded by the classical random noise, generates fake face image feature data, and inputs the fake face image feature data into the classical discriminant neural network to obtain the first prediction result. Input the reduced real face image data into the classical discriminant neural network to obtain the second prediction result. Figure 5 The real data in
[0052] refers to the reduced real face image data.
[0052] Among them, based on the basic quantum gate operations R y (θ), R z (θ), etc. of the quantum computer support, build a basic building block of the quantum generative neural network as Figure 4 shown. Build the network structure of the quantum generative neural network based on the basic building block as Figure 5 shown. In this embodiment, 16 qubits are used.
[0053] Figure 5 In Figure 4 U is the basic building block shown. Figure 5 In the dashed box part in
[0054] realizes quantum entanglement and quantum operations on classical random noise, and can be repeated multiple times to enhance the performance of the generator, that is, the quantum generative neural network. In this embodiment, the number of repetitions l = 3 is selected, and the Pauli-Z expectation of each qubit of the generator, that is, the quantum generative neural network, is measured as the fake face image feature data. Figure 6As shown, the classical discriminant neural network consists of multiple layers of classical fully-connected neural networks. The number of neural network nodes in each layer of the classical fully-connected neural network is [16, 100, 10, 1]. The dimension of the input layer is 16, which is used to input 16-dimensional fake face image feature data and the downsampled real face image data. The dimension of the output layer is 1. The output layer performs a sigmoid function on the input fake face image feature data and the downsampled real face image data, obtaining the prediction result for the input fake face image feature data, i.e., the first prediction result, and the prediction result for the input downsampled real face image data, i.e., the second prediction result. By the prediction results, it is determined whether the input face image is fake face image feature data or downsampled real face image data. A prediction result of 1 indicates that the input is downsampled real face image data, and a prediction result of 0 indicates that the input is fake face image feature data.
[0055] S4. Combine the first prediction result and the second prediction result into the first loss function for training the classical discriminant neural network, and update the parameters of the classical discriminant neural network according to the first loss function;
[0056] The first loss function LD is: LD = -E x [log(D(x))] - E z [log(1 - D(G(z)))],E x [log(D(x))] represents the average of the second prediction results D(x) of the classical discriminant neural network, i.e., the discriminator, for each downsampled real face image data x in the training dataset batch, E z [log(1 - D(G(z)))] represents the average of the first prediction results D(G(z)) of the classical discriminant neural network, i.e., the discriminator, for each fake real face image data z in the training dataset batch. Take the batch size as 100, which can also be set according to the actual situation. Then, update the parameters of the classical discriminant neural network based on the first loss function.
[0057] S5. After the number of times of updating the parameters of the classical discriminant neural network reaches the preset number threshold, input the fake face image feature data into the current classical discriminant neural network to obtain the prediction result. According to the prediction result, construct the second loss function for training the quantum generative neural network, and update the parameters of the quantum generative neural network according to the second loss function until the current classical discriminant neural network discriminates the fake face image feature data as real;
[0058] S6. Return to execute S1 until the latest obtained classical discriminant neural network cannot determine whether it is fake face image feature data;
[0059] Among them, the preset number threshold can be set according to the actual situation.
[0060] Among them, before updating the parameters of the quantum generation neural network according to the second loss function, it also includes: fixing the parameters of the current classical discriminant neural network.
[0061] Among them, the second loss function is: LG = -E z [log(D(G(z)))] Based on this second loss function, update the parameters of the generator, that is, the quantum generation neural network, so that the current classical discriminant neural network discriminates the false face image feature data as true. There is an adversarial relationship between the generator, that is, the quantum generation neural network, and the discriminator, that is, the classical discriminant neural network. The purpose of the classical discriminant neural network is to distinguish whether the input is the downsampled real face image data or the false face image feature data. The purpose of the generator, that is, the quantum generation neural network, is to make the discriminator recognize the false face image feature data as true. That is to say, make the latest obtained classical discriminant neural network unable to distinguish that the face image feature data input by the latest obtained quantum generation neural network to the latest obtained classical discriminant neural network is false.
[0062] S7. Use the latest obtained quantum generation neural network to generate face image feature data.
[0063] Optionally, in the above technical solution, the process of obtaining the downsampled real face image data includes: performing auto-encoding on the real face image data according to the number of qubits used by the quantum generation neural network to obtain the downsampled real face image data.
[0064] Among them, the implementation method of updating the quantum generation neural network is: based on the parameterized circuit movement rule, update the quantum generation neural network, and a measurement operator The expected value function f(θ i ) under the parameterized quantum circuit U(θ i ) can be expressed as Then the gradient i of the expected value function f(θ i ) with respect to the parameterized quantum circuit parameter θ can be expressed as: The U(θ i ) in the expected value function f(θ i ) represents the parameterized quantum circuit that constitutes the generator, that is, the quantum generation neural network, and θ i represents the parameters in the quantum neural network that operate on the node feature vectors integrating graph information. This method is called the parameter movement rule for analyzing the gradient of the expected value of the operator constructed by the parameterized quantum circuit with respect to the parameterized quantum circuit parameters.
[0065] Through the parameter movement rule, the analytical gradient of the second loss function with respect to the parameters of the quantum generative neural network can be obtained. Then, the parameters of the quantum generative neural network are updated using a classical computer through the gradient descent method, and the parameters of the classical discriminative neural network are updated using the backpropagation algorithm. Finally, after the classical discriminative neural network and the quantum generative neural network are adversarially trained multiple times and converge, the trained generator of the present invention, i.e., the newly obtained quantum generative neural network, can be used to generate face image feature data.
[0066] Among them, the process of updating the parameters of the classical discriminative neural network is as follows: The parameters of the classical discriminative neural network are trained and updated based on the training set and validation set of the real face image data set.
[0067] In the present invention, a self-designed hybrid quantum-classical generative adversarial neural network is adopted. First, the real face image data is auto-encoded based on the number of qubits used by the quantum generative neural network to achieve dimensionality reduction of features. Then, classical random noise is loaded into the quantum state through angle encoding. Then, the quantum generative neural network generates fake face image data features with the same dimension as the dimensionality-reduced real face image data. Then, the face image feature data generated by the quantum generative neural network and the dimensionality-reduced real face image feature data are respectively input into the constructed classical discriminative neural network. Then, the classical discriminative neural network outputs the prediction results for the real data and the data generated by the quantum generative neural network. The discrimination results for the real data and the generated data are combined into the loss function for training the classical discriminative neural network. The parameters of the classical discriminative neural network are updated according to the obtained loss function corresponding to the classical discriminative neural network so that the discriminator can well identify whether the input is a real picture or the picture features generated by the generator. After the set number of times of updating the parameters of the classical discriminative neural network, by inputting the face image feature data generated by the quantum generative neural network into the classical discriminative neural network, the loss function for training the quantum generative neural network is constructed according to the prediction results of the classical discriminative neural network for the generated face image feature data. Then, according to this loss function, the parameters of the discriminator are fixed, and the parameters of the generator are updated so that the discriminator discriminates the generated face image as real. Through the continuous confrontation between the generator and the discriminator, finally, the discriminator will not be able to distinguish whether the input is a generated face image or a real face image. Finally, we can use the trained generator to generate new face images that are different from and similar to the real face images.
[0068] The hybrid quantum-classical generative adversarial neural network proposed by the present invention adopts a brand-new computing mode based on the basic principles of quantum mechanics, namely quantum computing. Due to the powerful parallelism and non-local characteristics of the quantum neural network, our model is superior to the classical generative adversarial neural network in terms of the extraction of global features of face images and the convergence speed, and is simpler than the classical neural network in the design of the neural network model and the adjustment of hyperparameters. It is expected to outperform classical machine learning algorithms in terms of the effect of image generation. Moreover, the present invention uses a classical neural network to execute the discriminator task and only uses a quantum neural network to implement the generator, thereby reducing the hardware resource requirements for a real quantum computer and applying it to the face image generation task, so that we can better utilize the currently developed quantum computers in real fields. At present, there is no specific research on the face image generation task in combination with quantum computing, and the training stability of the hybrid quantum-classical generative adversarial neural network is expected to exceed that of pure classical machine learning algorithms.
[0069] In the above embodiments, although the steps are numbered S1, S2, etc., they are only specific embodiments given by the present invention. Those skilled in the art can adjust the execution order of S1, S2, etc. according to the actual situation, which is also within the protection scope of the present invention. It can be understood that in some embodiments, it may include some or all of the above embodiments.
[0070] A face image generation system based on a hybrid quantum-classical generative adversarial neural network according to an embodiment of the present invention includes a random noise quantum state encoding module, a training module, and a face image feature data generation module;
[0071] The random noise quantum state encoding module is used to: load classical random noise as a quantum state;
[0072] The training module is used to: operate on a quantum state using a quantum generative neural network to generate fake face image feature data, where the dimension of the fake face image feature data is the same as that of the downsampled real face image data; input the fake face image feature data into a classical discriminative neural network to obtain a first prediction result, and input the downsampled real face image data into the classical discriminative neural network to obtain a second prediction result; combine the first prediction result and the second prediction result into a first loss function for training the classical discriminative neural network, and update the parameters of the classical discriminative neural network according to the first loss function; when the number of times of updating the parameters of the classical discriminative neural network reaches a preset number threshold, input the fake face image feature data into the current classical discriminative neural network to obtain a prediction result, and construct a second loss function for training the quantum generative neural network according to the prediction result, and update the parameters of the quantum generative neural network according to the second loss function, so that the current classical discriminative neural network discriminates the fake face image feature data as real, and recall the random noise quantum state encoding module until the latest obtained classical discriminative neural network cannot determine whether it is fake face image feature data;
[0073] The face image feature data generation module is used to: generate face image feature data using the latest obtained quantum generative neural network.
[0074] Optionally, in the above technical solution, the random noise quantum state encoding module is specifically used to: load classical random noise as a quantum state by means of angle encoding.
[0075] Optionally, in the above technical solution, the training module is further specifically used to: fix the parameters of the current classical discriminative neural network before updating the parameters of the quantum generative neural network according to the second loss function.
[0076] Optionally, in the above technical solution, it further includes a real face image data preprocessing module, and the real face image data preprocessing module is used to: perform autoencoding on the real face image data according to the number of qubits used by the quantum generative neural network to obtain the downsampled real face image data.
[0077] It should be noted that the beneficial effects of the face image generation system based on the hybrid quantum-classical generative adversarial neural network provided in the above embodiments are the same as those of the face image generation method based on the hybrid quantum-classical generative adversarial neural network, which will not be elaborated here. In addition, when the system provided in the above embodiments implements its functions, only the division of the above functional modules is used as an example for illustration. In practical applications, the above functions can be allocated to different functional modules according to needs, that is, the system can be divided into different functional modules according to the actual situation to complete all or part of the functions described above. In addition, the system and method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process can be seen in the method embodiments, which will not be elaborated here.
[0078] In another embodiment, it includes a real face image data preprocessing and random noise quantum state encoding module, a generator and discriminator construction module, a discriminator training module, a generator training module, and a quantum circuit parameter updating module.
[0079] The real face image data preprocessing and random noise quantum state encoding module is used to: download the real face image dataset in reality, process the face images, and reduce the dimensionality of the real face image data to the same dimension as the number of qubits used by the generator through an auto-encoding method according to the number of qubits used by the generator. Encode the classical random noise into a quantum state by angle encoding, so as to generate fake face image features through the generator designed later.
[0080] The generator and discriminator construction module is used to: based on the quantum operations supported by the quantum computer, construct a generator and a discriminator according to the characteristics of the real dataset, for generating fake face image features and distinguishing between real face images and generated face images.
[0081] The discriminator training module is used to: combine the discrimination results of the discriminator on the input real face image data and generated face image data into a loss function, and then update the parameters of the discriminator based on the loss function, so that the discriminator can distinguish whether the input is a real face image or a face image generated by the generator.
[0082] The generator training module is used to: construct a loss function according to the prediction results obtained by inputting the face image feature data generated by the generator into the classical discriminant neural network, then fix the parameters of the discriminator, and update the parameters of the generator based on this loss function, so that the discriminator discriminates the face image generated by the generator as real.
[0083] The quantum circuit parameter update module is used to: based on the existing parameterized circuit movement rules, find the analytical gradient of the loss function of the generator with respect to the quantum circuit parameters, so that we can use a classical computer to update the parameters of the generator. The parameters of the discriminator can be updated through the backpropagation algorithm of the machine learning framework. Finally, by training the discriminator and the generator adversarially multiple times, the face image generation method based on the hybrid quantum-classical generative adversarial neural network proposed by the present invention converges and then stops.
[0084] Specifically, it is illustrated through the following embodiments:
[0085] Real face image data preprocessing and random noise quantum state encoding module: Download the CelebA real face image dataset, then convert the pixel channels in the dataset to one channel through the averaging method, reduce the 178×218-dimensional face image data to 16 dimensions through the autoencoder method, and then randomly take 32 numbers r = [r1…r 32 from the standard normal distribution as external classical random noise. Take the arctangent of each element of the classical random noise r, and through the formula θ i = arctan(r i ) to obtain the rotation angle of the quantum gate. Note that here r i represents one of the 32 classical random noises taken, and θ i represents the rotation angle of the i-th quantum gate in the generator, and i represents the serial number of the classical random noise. Then, load the classical random noise onto the amplitude of the quantum state by rotating the quantum gate through R y (θ) and R x (θ). Here, 16 qubits are used, and the specific quantum circuit is as Figure 2 shown.
[0086] Generator and discriminator construction module:
[0087] The overall architecture of the hybrid quantum-classical generative adversarial neural network designed by the present invention is as Figure 3 shown. Among them, DNN represents the classical discriminant neural network. Based on the real face image data after dimensionality reduction in the previous module and the random noise quantum state encoding module, the classical random noise is input into the generator through quantum state encoding to generate 16-dimensional face image feature data. Then, the generated face image data and the real face image data are respectively input into the discriminator to obtain the prediction results of the discriminator for the input data.
[0088] Based on the basic quantum gate operations R y (θ), R z (θ), etc. supported by the quantum computer, build a basic construction module of the quantum generative neural network as Figure 4 shown. Based on this basic construction module, build the quantum generative neural network, and its network structure is asFigure 5 As shown, 16 qubits are used here. Figure 5 The encoding module in Figure 2 is the random noise quantum state encoding module of Figure 4 . The structure of U is as Figure 5 shown. The part within the dashed box in realizes quantum entanglement and quantum operations on classical random noise. It can be repeated multiple times to enhance the performance of the generator. Here, we choose the number of repetitions l = 3. Finally, the Pauli-Z expectation of each qubit of the generator is measured to obtain the generated face image feature information.
[0089] After obtaining the fake face image data generated by the quantum generative neural network, the generated fake face image and the feature data of the real face image after dimensionality reduction can be input into the discriminator, that is, the classical discriminative neural network. The structure of the discriminator is as Figure 6 shown. It is composed of multiple layers of classical fully connected neural networks. The number of neural network nodes in each layer is [16, 100, 10, 1]. The dimension of the input layer is 16, which is used to input 16-dimensional real and generated image feature data. The dimension of the output layer is 1. By performing a sigmoid function on the output as the prediction result of the input face image feature data, it is determined whether the input face image is a real image or a fake image. A prediction result of 1 indicates that the input is the feature of a real face image, and a result of 0 indicates that the input is the feature of a fake face image.
[0090] Training the discriminator module:
[0091] Input the 16-dimensional real face image data features and the face image features generated by the generator into the discriminator as Figure 6 shown, and obtain the prediction results of the discriminator for the input samples of real face images and the samples of generated face image features respectively. Then, according to these two prediction results, a loss function, that is, the first loss function, is combined as shown in the following formula:
[0092] LD = -E x [log(D(x))] - E z [log(1 - D(G(z)))]
[0093] where the symbol E x / z[ ] represents the average of the discriminator's prediction results for the feature data of real or generated face images over the training dataset batch. Here, the batch size is taken as 100, where x represents the feature data of real face images, z represents the classical random noise input to the generator, and G(z) represents the feature data of the face images generated after the generator operates on the classical random noise. D(x) represents the discriminator's prediction result for real face image samples, and D(G(z)) represents the discriminator's prediction result for generated face image samples. Then, based on the loss function of the discriminator constructed above, the parameters of the discriminator are updated so that the discriminator can distinguish whether the input is a real face image or a face image generated by the generator.
[0094] Training the generator module:
[0095] Based on the real face image data preprocessing and random noise quantum state encoding module, the 32-dimensional classical random noise is input into the generator, and then the generated face image feature data is input into the discriminator to obtain the discriminator's prediction result for constructing the loss function of the generator, that is, the second loss function, as shown in the following formula:
[0096] LG = -E z [log(D(G(z)))]
[0097] Then, fixing the parameters of the discriminator, the parameters of the generator are updated based on this loss function, so that the discriminator discriminates the face images generated by the generator as real. There is an adversarial relationship between the generator and the discriminator. The purpose of the discriminator is to distinguish whether the input is real face image data or fake face image data, and the purpose of the generator is to make the discriminator recognize it as a real face image, even if the discriminator cannot distinguish that the face image feature data input by the generator to the discriminator is fake.
[0098] Updating the quantum circuit parameter module:
[0099] The parameters in the generator proposed by the present invention can be updated through the following provided parameter movement rules. First, a measurement operator The expected value under the parameterized quantum circuit U(θ i ) can be expressed as:
[0100]
[0101] Then, the gradient of the expected value function f(θ i ) with respect to the parameterized quantum circuit parameter θ i can be expressed as: The above formula The U(θ i ) in iDenote the parameters in generator U. The above method is called the parameter-shift rule for analyzing the gradient of the operator expectation value with respect to the parameters of the parameterized quantum circuit.
[0102] Through the parameter-shift rule, the analytical gradient of the previous module, i.e., the second loss function, with respect to the generator parameters can be obtained. Then, the parameters of the generator are updated using the gradient descent method on a classical computer, and the parameters of the discriminator are updated using the backpropagation algorithm. Finally, by training the discriminator and the generator against each other multiple times, the face image generation method based on the hybrid quantum-classical generative adversarial neural network proposed by the present invention is stopped after convergence, so that the face image data can be generated using the trained generator of the present invention.
[0103] As Figure 7 shown, a computer device 300 according to an embodiment of the present invention. The computer device 300 includes a processor 320, the processor 320 is coupled to a memory 310, and at least one computer program 330 is stored in the memory 310. The at least one computer program 330 is loaded and executed by the processor 320 to enable the computer device 300 to implement any one of the above-mentioned face image generation methods based on the hybrid quantum-classical generative adversarial neural network. Specifically:
[0104] The computer device 300 may vary greatly due to configuration or performance differences. It may include one or more processors 320 (Central Processing Units, CPUs) and one or more memories 310. Among them, at least one computer program 330 is stored in the one or more memories 310, and the at least one computer program 330 is loaded and executed by the one or more processors 320 to enable the computer device 300 to implement any one of the face image generation methods based on the hybrid quantum-classical generative adversarial neural network provided in the above embodiments. Of course, the computer device 300 may also have components such as a wired or wireless network interface, a keyboard, and an input / output interface for input and output. The computer device 300 may further include other components for implementing the functions of the device, which will not be elaborated here.
[0105] A computer-readable storage medium according to an embodiment of the present invention stores at least one computer program, and the at least one computer program is loaded and executed by a processor to enable a computer to implement any one of the above-mentioned face image generation methods based on the hybrid quantum-classical generative adversarial neural network.
[0106] Optionally, the computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a compact disc read-only memory (CD-ROM), magnetic tape, floppy disk, and optical data storage device, etc.
[0107] In an exemplary embodiment, there is also provided a computer program product or a computer program. The computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes any one of the above-mentioned face image generation methods based on the hybrid quantum-classical generative adversarial neural network.
[0108] It should be noted that the terms "first", "second", etc. in the description and claims of the present application are used to distinguish similar objects, and do not represent a limitation on a specific order or sequence. In appropriate cases, the order of use of similar objects may be interchanged, so that the embodiments of the present application described herein can be implemented in an order other than the illustrated or described order.
[0109] Those skilled in the art know that the present invention can be implemented as a system, a method, or a computer program product. Therefore, the present invention can be specifically implemented in the following forms: it can be entirely hardware, can be entirely software (including firmware, resident software, microcode, etc.), or can be a combination of hardware and software, generally referred to as "circuit", "module", or "system" herein. In addition, in some embodiments, the present invention can also be implemented in the form of a computer program product in one or more computer-readable media, and the computer-readable media contain computer-readable program codes.
[0110] Any combination of one or more computer-readable media may be employed. The computer-readable media may be a computer-readable signal medium or a computer-readable storage medium. A computer-readable storage medium may be, for example - but not limited to - an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the computer-readable storage medium include: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, the computer-readable storage medium may be any tangible medium that contains or stores a program which can be used by or in connection with an instruction execution system, apparatus, or device.
[0111] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those of ordinary skill in the art may make changes, modifications, substitutions, and variations to the above embodiments within the scope of the present invention.
Claims
1. A face image generation method based on a hybrid quantum-classical generative adversarial neural network, characterized in that, Including: S1. Loading classical random noise as a quantum state; The process of obtaining classical random noise is as follows: randomly select 32 numbers from the standard normal distribution, denoted as r = [r1…r 32 , and use r as the classical random noise; S2. Using a quantum generative neural network to operate on the quantum state to generate fake face image feature data, where the dimension of the fake face image feature data is the same as that of the dimension-reduced real face image data; Among them, based on the basic quantum gate operations supported by a quantum computer, the basic building block U of the quantum generative neural network is constructed. Quantum entanglement and quantum operations on classical random noise are realized based on multiple basic building blocks U. The Pauli-Z expectation of each qubit of the quantum generative neural network is used as the fake face image feature data; Among them, the basic building block U includes a two-bit CNOT quantum gate and four basic rotation quantum gates. The four basic rotation quantum gates include R y (θ1), R z (θ2), R y (θ4), and R z (θ5). R y (θ1) and R y (θ4) are connected to R z (θ2) and R z (θ5) through the two-bit CNOT quantum gate; Among them, the quantum generative neural network includes multiple layers, and each layer includes two groups of basic building blocks U. Each adjacent two basic building blocks U in the first group of basic building blocks U are jointly connected to one basic building block U in the second group; between two adjacent layers of the quantum generative neural network, each basic building block U in the second group of the previous layer is respectively connected to two adjacent basic building blocks U in the first group of the next layer. The first basic building block U in the first group of the previous layer is connected to the first basic building block U in the first group of the next layer, and the last basic building block U in the first group of the previous layer is connected to the last basic building block U in the first group of the next layer. The encoded quantum state is input into the basic building block U in the first group of the first layer of the quantum generative neural network; S5. Inputting the fake face image feature data into a classical discriminant neural network composed of multiple layers of classical fully connected neural networks to obtain a first prediction result, and inputting the dimension-reduced real face image data into the classical discriminant neural network to obtain a second prediction result; S6. Combining the first prediction result and the second prediction result into a first loss function for training the classical discriminant neural network, and updating the parameters of the classical discriminant neural network according to the first loss function; S7. After the number of times of updating the parameters of the classical discriminant neural network reaches a preset number threshold, inputting the fake face image feature data into the current classical discriminant neural network to obtain a prediction result, and constructing a second loss function for training the quantum generative neural network according to the prediction result, and updating the parameters of the quantum generative neural network according to the second loss function, so that the current classical discriminant neural network discriminates the fake face image feature data as real; Among them, the first loss function \(L_D\) is: \(L_D = -E\) x [\log(D(x))] - E z [\log(1 - D(G(z)))],E x [\log(D(x))] represents: the average of the second prediction result \(D(x)\) of the classical discriminant neural network for each dimensionality-reduced real face image data \(x\) in the training data set batch, \(E\) z [\log(1 - D(G(z)))] represents: the average of the first prediction result \(D(G(z))\) of the classical discriminant neural network for each fake real face image data \(z\) in the training data set; wherein, the second loss function is: LG = -E z [log(D(G(z)))]; S8. Returning to execute S1 until the latest obtained classical discriminant neural network cannot determine whether it is fake face image feature data; S9. Using the latest obtained quantum generative neural network to generate face image feature data.
2. The face image generation method based on a hybrid quantum-classical generative adversarial neural network according to claim 1, wherein, Loading classical random noise as a quantum state includes: Loading classical random noise as a quantum state by means of angle encoding.
3. A face image generation method based on a hybrid quantum-classical generative adversarial neural network according to claim 1, characterized in that Before updating the parameters of the quantum generative neural network according to the second loss function, it further includes: Fixing the parameters of the current classical discriminant neural network.
4. A face image generation method based on a hybrid quantum-classical generative adversarial neural network according to claim 1, characterized in that, The acquisition process of the dimension-reduced real face image data includes: Auto-encode the real face image data according to the number of qubits used in the quantum generative neural network to obtain the real face image data after dimensionality reduction.
5. A face image generation system based on a hybrid quantum-classical generative adversarial neural network, characterized in that, It includes a random noise quantum state encoding module, a training module, and a face image feature data generation module; The random noise quantum state encoding module is used to: load classical random noise as a quantum state; The process of obtaining classical random noise is as follows: randomly select 32 numbers from the standard normal distribution, denoted as r = [r1…r 32 , and use r as the classical random noise; The training module is used to: operate on the quantum state using the quantum generative neural network to generate fake face image feature data, where the dimension of the fake face image feature data is the same as that of the real face image data after dimensionality reduction; input the fake face image feature data into a classical discriminant neural network composed of multiple layers of classical fully connected neural networks to obtain a first prediction result, and input the real face image data after dimensionality reduction into the classical discriminant neural network to obtain a second prediction result; combine the first prediction result and the second prediction result into a first loss function for training the classical discriminant neural network, and update the parameters of the classical discriminant neural network according to the first loss function; when the number of times of updating the parameters of the classical discriminant neural network reaches a preset number threshold, input the fake face image feature data into the current classical discriminant neural network to obtain a prediction result, and construct a second loss function for training the quantum generative neural network according to the prediction result, and update the parameters of the quantum generative neural network according to the second loss function, so that the current classical discriminant neural network discriminates the fake face image feature data as real, and then re-call the random noise quantum state encoding module until the latest obtained classical discriminant neural network cannot determine whether it is fake face image feature data; Among them, a basic building block U of the quantum generative neural network is constructed based on the basic quantum gate operations supported by the quantum computer. Quantum entanglement and quantum operations on classical random noise are realized based on multiple basic building blocks U, and the Pauli-Z expectation of each qubit of the quantum generative neural network is used as the fake face image feature data; Among them, the basic building block U includes a two-bit CNOT quantum gate and four basic rotation quantum gates. The four basic rotation quantum gates include R y (θ1), R z (θ2), R y (θ4) and R z (θ5). R y (θ1) and R y (θ4) are connected to R z (θ2) and R z (θ5) through the two-bit CNOT quantum gate; Among them, the quantum generative neural network includes multiple layers, and each layer includes two groups of basic building blocks U. Each adjacent two basic building blocks U in the first group of basic building blocks U are jointly connected to one basic building block U in the second group; between adjacent layers of the quantum generative neural network, each basic building block U in the second group of the previous layer is respectively connected to two adjacent basic building blocks U in the first group of the next layer, the first basic building block U in the first group of the previous layer is connected to the first basic building block U in the first group of the next layer, and the last basic building block U in the first group of the previous layer is connected to the last basic building block U in the first group of the next layer, and the encoded quantum state is input into the basic building block U in the first group of the first layer of the quantum generative neural network; Among them, the first loss function \(L_D\) is: \(L_D=-E\) x [\log(D(x))]-E z [\log(1 - D(G(z)))],E x [\log(D(x))] represents: the average of the second prediction result \(D(x)\) of the classical discriminant neural network for each dimensionality-reduced real face image data \(x\) in the training data set batch, \(E\) z [\log(1 - D(G(z)))] represents: the average of the first prediction result \(D(G(z))\) of the classical discriminant neural network for each fake real face image data \(z\) in the training data set; wherein, the second loss function is: LG = -E z [log(D(G(z)))]; The face image feature data generation module is used to: generate face image feature data using the latest obtained quantum generative neural network.
6. The face image generation system based on a hybrid quantum-classical generative adversarial neural network according to claim 5, wherein, The random noise quantum state encoding module is specifically configured to: load classical random noise as a quantum state by means of angle encoding.
7. A face image generation system based on a hybrid quantum-classical generative adversarial neural network according to claim 5, characterized in that, The training module is further specifically configured to: before updating the parameters of the quantum generation neural network according to the second loss function, fix the parameters of the current classical discriminant neural network.
8. A face image generation system based on a hybrid quantum-classical generative adversarial neural network according to claim 5, characterized in that, It further includes a real face image data preprocessing module, and the real face image data preprocessing module is configured to: perform autoencoding on the real face image data according to the number of qubits used by the quantum generation neural network to obtain the downsampled real face image data.
9. A computer device, characterized in that, The computer device includes a processor, the processor is coupled to a memory, and at least one computer program is stored in the memory. The at least one computer program is loaded and executed by the processor to enable the computer device to implement a face image generation method based on a hybrid quantum-classical generative adversarial neural network as described in any one of claims 1 to 4.
10. A computer-readable storage medium, characterized in that, At least one computer program is stored in the computer-readable storage medium. The at least one computer program is loaded and executed by a processor to enable a computer to implement a face image generation method based on a hybrid quantum-classical generative adversarial neural network as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Training method of hybrid quantum classical generative adversarial network and related equipment
CN115311515A