Commodity Image Generation Method Based on Quantum Generative Adversarial Neural Network
Through quantum generation and adversarial neural networks, classic random noise is loaded into quantum states, and quantum generation and discriminant neural network training is used to solve the complexity of data processing and network design in popular product image generation, achieving faster feature extraction and convergence, and better generation effect.
Patent Information
- Application Number
- CN202410357243.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-27
- Publication Date
- 2025-07-22
- Estimated Expiration
- 2044-03-27
AI Technical Summary
When generating popular product images based on machine learning models, existing classic computers have problems such as insufficient data processing capabilities, complex neural network design and difficult hyperparameter adjustment, making it difficult to effectively learn data pattern information.
Using a method based on quantum generation and adversarial neural network, classic random noise is loaded into quantum states, quantum generation neural network is used to generate fake commodity image feature data, and through quantum discrimination neural network training, the parameters of the quantum discrimination neural network and the generation neural network are optimized, so that it can be executed on a NISQ real quantum computer.
Quantum generation adversarial neural networks are better than classical neural networks in the global feature extraction and convergence speed of commodity images. The model design and hyperparameter adjustment are simple, suitable for execution on existing quantum computers, and the generation effect exceeds that of classic machine learning algorithms.
Smart Images

Figure CN118247373B_ABST
Abstract
Description
Background Art
[0002] Product style design plays a crucial role in today's market. It is not only a manifestation of the external beauty of products, but also a key factor in brand image, user experience, and business success. A uniquely styled and eye-catching product design can quickly attract consumers' attention and stimulate their desire to purchase. Designers skillfully blend product functions with aesthetics through ingenious color combinations, unique material applications, and creative layout designs, bringing consumers a pleasant user experience. At the same time, product style design is also an important means of shaping brand image, capable of conveying the values and cultural characteristics of enterprises. Style design can also increase the added value of products, making them more competitive in the market, thus bringing considerable commercial returns to enterprises. Therefore, product style design plays an indispensable role in a successful product, a beloved brand, and a stable business model. Currently, the generation of images of popular products is mainly processed through classical machine learning, and the realization of generating popular products based on quantum machine learning has not been involved yet.
[0003] Existing technologies generate popular products based on machine learning models on classical computers. Classical computers perform calculations based on classical bits, which are quite different from the quantum bits used by quantum computers for information processing. In the case of the same number of bits, quantum computers can process more data due to their huge Hilbert space. Due to the limitations of its implementation mechanism, classical neural networks may not be able to learn some pattern information in the data. Currently, when using classical neural networks for learning, a relatively complex design of neural network models and adjustment techniques for hyperparameters are required, and a large amount of data is needed for training. Summary of the Invention
[0004] The technical problem to be solved by the present invention is to address the deficiencies of the prior art, and specifically provide a method for generating product images based on a quantum generative adversarial neural network, as follows:
[0005] 1) In a first aspect, the present invention provides a method for generating product images based on a quantum generative adversarial neural network, and the specific technical solution is as follows:
[0006] S1. Load classical random noise as a quantum state;
[0007] S2. Use a quantum generative neural network to operate on the quantum state to generate fake product image feature data, and the dimension of the fake product image feature data is the same as the dimension of the real product image data after dimensionality reduction;
[0008] S3. Input the fake product image feature data into a quantum discriminative neural network to obtain a first prediction result, and input the real product image data after dimensionality reduction into the quantum discriminative neural network to obtain a second prediction result;
[0009] S4. Combine the first prediction result and the second prediction result into a first loss function for training the quantum discriminant neural network, and update the parameters of the quantum discriminant neural network according to the first loss function;
[0010] S5. When the number of times of updating the parameters of the quantum discriminant neural network reaches the preset number threshold, input the fake commodity image feature data into the current quantum discriminant neural network to obtain a prediction result. 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 quantum discriminant neural network discriminates the fake commodity image feature data as true;
[0011] S6. Return to execute S1 until the latest obtained quantum discriminant neural network cannot determine whether it is fake commodity image feature data;
[0012] S7. Use the latest obtained quantum generative neural network to generate commodity image data.
[0013] The beneficial effects of a commodity image generation method based on a quantum generative adversarial neural network provided by the present invention are as follows:
[0014] Adopt 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, the latest obtained quantum generative neural network in the present invention is superior to the classical neural network in both the extraction of global features and the convergence speed of commodity images, and is simpler than the classical neural network in the design of the quantum generative neural network and the adjustment of hyperparameters, and is suitable for execution on the current NISQ real quantum computer.
[0015] On the basis of the above solution, a commodity image generation method based on a quantum generative adversarial neural network of the present invention can also be improved as follows.
[0016] 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.
[0017] Further, when updating the parameters of the quantum generative neural network according to the second loss function, it further includes: fixing the parameters of the current quantum discriminant neural network.
[0018] Further, the process of obtaining the dimension-reduced real commodity image data includes: performing autoencoding on the real commodity image data according to the number of quantum bits used by the quantum generative neural network to obtain the dimension-reduced real commodity image data.
[0019] 2) Second aspect, the present invention also provides a commodity image generation system based on a quantum generative adversarial neural network, and the specific technical solution is as follows:
[0020] It includes a random noise quantum state encoding module, a training module, and a commodity image 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: use a quantum generative neural network to operate on the quantum state to generate fake commodity image feature data, and the dimension of the fake commodity image feature data is the same as the dimension of the downsampled real commodity image data; input the fake commodity image feature data into a quantum discriminative neural network to obtain a first prediction result, and input the downsampled real commodity image data into the quantum 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 quantum discriminative neural network, and update the parameters of the quantum discriminative neural network according to the first loss function; when the number of times of updating the parameters of the quantum discriminative neural network reaches a preset number threshold, input the fake commodity image feature data into the current quantum 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 quantum discriminative neural network discriminates the fake commodity image feature data as real; recall the random noise quantum state encoding module again until the latest obtained quantum discriminative neural network cannot determine whether it is fake commodity image feature data;
[0023] The commodity image data generation module is used to: generate commodity image data by using the latest obtained quantum generative neural network.
[0024] Based on the above solution, a commodity image generation system based on a quantum 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 through an angle encoding method.
[0026] Further, the training module is also specifically used to: fix the parameters of the current quantum 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 commodity image data downsampling module, and the real commodity image data downsampling module is used to: perform autoencoding on the real commodity image data according to the number of qubits used by the quantum generative neural network to obtain the downsampled real commodity 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 commodity image generation methods based on a quantum 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 commodity image generation methods based on a quantum 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 here. 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 commodity image generation method based on a quantum 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 overall architecture of a quantum generative adversarial neural network;
[0035] Figure 4 It is a basic building block;
[0036] Figure 5 It is the network structure of a quantum generative neural network;
[0037] Figure 6 It is the network structure of a quantum discriminant neural network;
[0038] Figure 7 It is the structure of P;
[0039] Figure 8 It is a schematic structural diagram of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0040] 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.
[0041] As shown Figure 1 in the figure, a method for generating a commodity image based on a quantum generative adversarial neural network according to an embodiment of the present invention includes the following steps:
[0042] S1. Loading classical random noise into a quantum state. Specifically, the classical random noise is loaded into the quantum state by means of angle encoding;
[0043] Among them, the process of obtaining classical random noise is: randomly taking 32 numbers in the standard normal distribution, denoted as r = [r1... r 32 , and taking r as the classical random noise.
[0044] The process of loading classical random noise into a quantum state by means of angle encoding is:
[0045] Taking the arctangent of each element in the classical random noise r, that is, r1... r 32 , that is, through the formula θ i = arctan(r i ), obtaining 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 corresponding rotation angle of the quantum gate, i represents the serial number of the 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, 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.
[0046] S2. Using a quantum generative neural network to operate on the quantum state to generate fake commodity image feature data, and the dimension of the fake commodity image feature data is the same as the dimension of the real commodity image data after dimensionality reduction;
[0047] Among them, the process of obtaining the real commodity image data after dimensionality reduction includes: performing auto-encoding on the real commodity image data according to the number of qubits used by the quantum generative neural network to obtain the real commodity image data after dimensionality reduction.
[0048] Among them, for the downloaded Fashion-MNIST real popular commodity image dataset, through the auto-encoding method, the 28×28-dimensional popular commodity image data is reduced to 16 dimensions. The popular commodity image data is the real commodity image data, and the 16-dimensional popular commodity image data is the real commodity image data after dimensionality reduction.
[0049] S3. Input the fake commodity image feature data into the quantum discriminant neural network to obtain a first prediction result, and input the dimension-reduced real commodity image data into the quantum discriminant neural network to obtain a second prediction result;
[0050] The quantum generative adversarial neural network includes a quantum generative neural network and a quantum discriminant neural network, and its overall architecture is as Figure 3 shown, Figure 3 where QDNN represents the quantum discriminant neural network, and the true / false data refers to the dimension-reduced real commodity image data and the fake commodity image feature data. Input the fake commodity image feature data and the dimension-reduced real commodity image data into the quantum discriminant neural network respectively to obtain corresponding prediction results.
[0051] Among them, based on the basic quantum gate operations R y (θ), R z (θ), etc., build a basic building block of the quantum generative neural network, as Figure 4 shown. Based on the basic building block as Figure 4 shown, the quantum generative neural network can be built, and the network structure of the quantum generative neural network is Figure 5 shown.
[0052] Figure 5 The "encoding" in refers to the process of "loading classical random noise as a quantum state through the angle encoding method". The structure of U is as Figure 4 shown, that is to say, U is the basic building block, Figure 5 The part within the dashed box in realizes quantum entanglement and quantum operations on classical random noise through ellipsis. It can be repeated multiple times to enhance the performance of the generator, that is, the quantum generative neural network. Here, the number of repetitions l = 3 is selected. Then, measure the Pauli-Z expectation of each qubit of the quantum generative neural network to obtain the fake commodity image feature data.
[0053] After generating the fake commodity image feature data, input the fake commodity image feature data and the dimension-reduced real commodity image data into the quantum discriminant neural network respectively. The network structure of the quantum discriminant neural network, that is, the discriminator, is as Figure 6 shown, Figure 6 The "encoding" in refers to the process of "loading classical random noise as a quantum state through the angle encoding method". 8 qubits are used, Figure 6 The U in is the Figure 4 shown basic building block, Figure 6 The structure of P in is as Figure 7As shown, it is used to realize the contraction of the quantum state characteristics of the quantum system. Finally, measure the Pauli-Z expectation of the remaining qubits. On a classical computer, perform a sigmoid function on the measurement result, that is, the Pauli-Z expectation of the remaining qubits, to obtain the prediction result of the input commodity image feature data (fake commodity image feature data or the real commodity image data after dimensionality reduction), and determine whether the input commodity image feature data is the real commodity image data after dimensionality reduction or fake commodity image feature data. A prediction result of 1 indicates that the input is the real commodity image data after dimensionality reduction, and a result of 0 indicates fake commodity image feature data.
[0054] S4. Combine the first prediction result and the second prediction result into the first loss function for training the quantum discriminant neural network, and update the parameters of the quantum discriminant neural network according to the first loss function;
[0055] Among them, the first loss function LD is: LD = -E x [log(D(x))] - E z [log(1 - D(G(z)))] where E x [log(D(x))] means: the average of the second prediction result D(x) of the quantum discriminant neural network, that is, the discriminator, for each real commodity image data x after dimensionality reduction in the training data set batch. E z [log(1 - D(G(z)))] means: the average of the first prediction result D(G(z)) of the quantum discriminant neural network, that is, the discriminator, for each fake commodity image feature data z in the training data set batch. Take the batch size as 100, and it can also be set according to the actual situation. Then, update the parameters of the quantum discriminant neural network based on the first loss function.
[0056] S5. When the number of times of updating the parameters of the quantum discriminant neural network reaches the preset number threshold, input the fake commodity image feature data into the current quantum 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, so that the current quantum discriminant neural network discriminates the fake commodity image feature data as real;
[0057] S6. Return to execute S1 until the latest obtained quantum discriminant neural network cannot determine whether it is fake commodity image feature data;
[0058] Among them, the preset number threshold can be set according to the actual situation.
[0059] Among them, updating the parameters of the quantum generative neural network according to the second loss function also includes: fixing the parameters of the current quantum discriminant neural network.
[0060] Among them, the second loss function LG is: LG = -E z [log(D(G(z)))]. Based on this second loss function, update the parameters of the quantum generative neural network, so that the current quantum discriminative neural network discriminates the fake commodity image feature data as real. There is an adversarial relationship between the quantum generative neural network and the discriminator, that is, the quantum discriminative neural network. The purpose is to distinguish whether the input is the real commodity image feature data after dimensionality reduction or the fake commodity image feature data. The purpose of the generator, that is, the quantum generative neural network, is to make the discriminator recognize the fake commodity image feature data as real. That is to say, make the latest obtained quantum discriminative neural network unable to distinguish that the fake commodity image feature data input by the latest obtained quantum generative neural network into the latest obtained quantum discriminative neural network is fake.
[0061] S7. Use the latest obtained quantum generative neural network to generate commodity image data.
[0062] Among them, the implementation method of updating the quantum generative neural network and the quantum discriminative neural network is: based on the parameterized quantum circuit movement rule, update the quantum generative neural network and the quantum discriminative neural network. Specifically:
[0063] A measurement operator The expected value function f(θ i ) under the parameterized quantum circuit U(θ i ) can be expressed as Then the gradient of the expected value function f(θ i ) with respect to the parameterized quantum circuit parameter θ i The gradient Can be expressed as U(θ i ) in the expected value function f(θ i ) can be expressed as the parameterized quantum circuit that constitutes the quantum generative neural network or the quantum discriminative neural network, and θ i Represents the parameter in U or P in the quantum generative neural network or the quantum discriminative neural network. 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 parameter.
[0064] Through the parameter movement rule, the analytical gradients of the second loss function with respect to the parameters of the quantum generative neural network and the quantum discriminative neural network can be obtained, and then the parameters of the quantum generative neural network and the quantum discriminative neural network can be updated by the gradient descent method using a classical computer. Finally, by training the quantum discriminative neural network and the quantum generative neural network adversarially multiple times until convergence and then stopping, the generator trained by the present invention, that is, the latest obtained quantum generative neural network, can be used to generate commodity image data.
[0065] It should be noted that the real commodity image data in the present invention can be the real commodity image data of popular commodities. In this case, the quantum generative neural network obtained recently is used to generate the commodity image data of popular commodities. The real commodity image data in the present invention can also be the real commodity image data of the commodities specified by users. In this case, the quantum generative neural network obtained recently is used to generate the commodity image data of the commodities specified by users.
[0066] The present invention constructs an efficient quantum generative adversarial neural network model to realize the generation of popular commodities in different styles and reduce the number of training times. Specifically, the self-designed quantum generative adversarial neural network is adopted in the present invention. First, the dimensionality reduction of features is realized by autoencoding the real popular commodity image data based on the number of qubits used in the quantum generative neural network adopted in the present invention. Then, the classical random noise is loaded into the quantum state by the angle encoding method. Then, the quantum generative neural network is used to generate fake image data with the same dimension as the dimensionality-reduced real image data. Then, the image feature data generated by the quantum generative neural network and the dimensionality-reduced real image feature data are respectively input into the constructed quantum discriminant neural network. Then, the quantum discriminant neural network is measured to obtain 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 quantum discriminant neural network. According to the obtained loss function corresponding to the quantum discriminant neural network, the parameters of the quantum discriminant neural network are updated so that the discriminator can well identify whether the input is the feature of a real picture or the picture generated by the generator. After the number of times set for the parameter update of the quantum discriminant neural network, by inputting the image feature data generated by the quantum generative neural network into the quantum discriminant neural network, the loss function for training the quantum generative neural network is constructed according to the prediction results for the generated image feature data obtained by measuring the quantum discriminant neural network. 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 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 image or a real image. Finally, the trained generator can be used to generate new images that are different from and similar to the real images. The beneficial effects are as follows:
[0067] The quantum 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, the model in the present invention is superior to the classical generative adversarial neural network in terms of the extraction of global features of popular commodity 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, and is expected to exceed the classical machine learning algorithm in terms of the image generation effect. Moreover, both the generator and discriminator of the quantum generative adversarial neural network model proposed by the present invention are completely implemented by quantum neural networks, and this model is suitable for execution on the current NISQ real quantum computer, so that the generation task of popular commodity images can be executed using the existing real quantum computer now. At present, there is no specific research on the generation task of popular commodity images in combination with quantum computing, and the training stability of the quantum generative adversarial network is expected to exceed the classical machine learning algorithm.
[0068] In the above embodiments, although the steps are numbered S1, S2, etc., these 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, and this 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.
[0069] A commodity image generation system based on a quantum 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 commodity image data generation module;
[0070] The random noise quantum state encoding module is used to: load classical random noise as a quantum state;
[0071] The training module is used to: operate on a quantum state using a quantum generative neural network to generate fake commodity image feature data, where the dimension of the fake commodity image feature data is the same as that of the real commodity image data after dimensionality reduction; input the fake commodity image feature data into the quantum discriminative neural network to obtain a first prediction result, and input the real commodity image data after dimensionality reduction into the quantum 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 quantum discriminative neural network, and update the parameters of the quantum discriminative neural network according to the first loss function; when the number of times of updating the parameters of the quantum discriminative neural network reaches a preset number threshold, input the fake commodity image feature data into the current quantum 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 quantum discriminative neural network discriminates the fake commodity image feature data as real; re - call the random noise quantum state encoding module until the latest obtained quantum discriminative neural network cannot determine whether it is fake commodity image feature data;
[0072] The commodity image data generation module is used to: generate commodity image data using the latest obtained quantum generative neural network.
[0073] Optionally, in the above - mentioned technical solution, the random noise quantum state encoding module is specifically used to: load classical random noise as a quantum state through an angle encoding method.
[0074] Optionally, in the above - mentioned technical solution, the training module is also specifically used to: fix the parameters of the current quantum discriminative neural network before updating the parameters of the quantum generative neural network according to the second loss function.
[0075] Optionally, in the above - mentioned technical solution, a real commodity image data dimensionality reduction module is further included, and the real commodity image data dimensionality reduction module is used to: perform auto - encoding on the real commodity image data according to the number of qubits used by the quantum generative neural network to obtain the real commodity image data after dimensionality reduction.
[0076] It should be noted that the beneficial effects of the commodity image generation system based on the quantum generative adversarial neural network provided in the above embodiments are the same as those of the commodity image generation method based on the quantum generative adversarial neural network, which will not be elaborated here. In addition, when the system provided in the above embodiments realizes 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 assigned 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 found in the method embodiments, which will not be elaborated here.
[0077] In another embodiment, it includes a real popular commodity 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.
[0078] The real popular commodity image data preprocessing and random noise quantum state encoding module is used to: reduce the dimensionality of the real popular commodity 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 classical random noise into a quantum state through angle encoding so that false image features can be generated by the generator designed later.
[0079] 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 data set for generating false image features and distinguishing between real images and generated images.
[0080] The discriminator training module is used to: combine the discrimination results of the discriminator on the real data and the generated data input into it 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 image or an image generated by the generator.
[0081] The generator training module is used to: input the image feature data generated by the generator into the quantum discriminative neural network, and finally construct a loss function according to the prediction results obtained by measuring the discriminator. 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 image generated by the generator as real.
[0082] The quantum circuit parameter updating module is used to: based on the existing parameterized quantum circuit movement rules, obtain the analytical gradients of the loss functions of the discriminator and the generator with respect to the quantum circuit parameters, so that the parameters of the discriminator and the generator can be updated using a classical computer. Finally, through multiple adversarial trainings of the discriminator and the generator, the commodity image generation method based on the quantum generative adversarial neural network proposed by the present invention converges and then stops.
[0083] It is illustrated by the following embodiments.
[0084] Real image data preprocessing and random noise quantum state encoding module:
[0085] By using the auto - encoding method, the downloaded Fashion - MNIST real fashion commodity image dataset reduces the 28×28 - dimensional fashion commodity image data to 16 dimensions. Then, 32 numbers r = [r1…r 32 are randomly taken from the standard normal distribution as external classical random noise. Take the arctangent of each element of the classical random noise r to obtain the rotation angle of the quantum gate. Specifically, through the formula θ i = arctan(r i ), the rotation angle of the quantum gate is obtained. 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, where i represents the serial number of the classical random noise. Then, through R y (θ) and R x (θ), the quantum gate is rotated to load the 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.
[0086] Generator and discriminator construction module:
[0087] The overall architecture of the quantum generative adversarial neural network designed in the present invention is as Figure 3 shown. Among them, QDNN represents the quantum discriminant neural network. Based on the real image data after dimensionality reduction in the previous module and the classical random noise quantum state encoding module, the random noise is input into the generator through quantum state encoding to generate 16 - dimensional fashion commodity image feature data. Then, the generated image data and the real image data are respectively input into the discriminator to obtain the prediction result 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, a basic construction module of the quantum generative neural network is built as Figure 4 shown. Based on this basic construction module, a quantum generative neural network can be built, and its network structure is as Figure 5 shown.
[0089] Figure 5 The encoding module in is the Figure 1 random noise quantum state encoding module implemented, and the structure of U is as Figure 4 shown. Figure 5The part within the dashed-line box realizes quantum entanglement and quantum operations on classical random noise. It can be repeated multiple times to enhance the performance of the generator. Here, the number of repetitions l = 3 is selected. Finally, the Pauli-Z expectation of each qubit of the generator is measured to obtain the characteristic information of the generated image.
[0090] After obtaining the fake popular commodity image data generated by the quantum generative neural network, the generated fake popular commodity images and the feature data of the real popular commodity images after dimensionality reduction can be input into the discriminator. The structure of the discriminator is as Figure 6 shown. It uses 8 qubits. The encoding module in the figure is used to encode the 16-dimensional real popular commodity image feature data and the image feature data generated by the above generator into quantum states. The implementation method is as Figure 2 shown. The structure of U is as Figure 4 shown and is used to perform quantum operations on the input generated face feature data and real face feature data. The structure of P in the figure is as Figure 7 shown and is used to realize the contraction of the quantum state characteristics of the quantum system. Finally, the Pauli-Z expectation of the remaining qubits is measured, and then a sigmoid function is executed on the measurement result on a classical computer as the prediction result for the input image feature data to determine whether the input image is a real image or a fake image. A prediction result of 1 indicates that the input is real image features, and a result of 0 indicates that the input is fake image features.
[0091] Training the discriminator module:
[0092] Through quantum state encoding, the real popular commodity image data features and the image data features generated by the generator are input into the discriminator as Figure 6 shown, and the prediction results of the discriminator for the real image input samples and the generated image feature data samples are obtained 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:
[0093] LD = -E x [log(D(x))] - E z [log(1 - D(G(z)))]
[0094] where the symbol E x / z[] represents the average of the discriminator's prediction results for the feature data of real or generated popular commodity images over the training dataset batch. Here, the batch size is taken as 100, where x represents the feature data of real popular commodity images, z represents the classical random noise input to the generator, and G(z) represents the feature data of the popular commodity images generated after the generator operates on the classical random noise. D(x) represents the discriminator's prediction result for real popular commodity image samples, and D(G(z)) represents the discriminator's prediction result for generated popular commodity 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 image or an image generated by the generator.
[0095] Training the generator module:
[0096] Based on the real popular commodity image data preprocessing and random noise quantum state encoding module, 32-dimensional classical random noise is input into the generator. Then, the generated feature data of the popular commodity images 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:
[0097] LG = -E z [log(D(G(z)))]
[0098] 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 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 image data or fake image data, and the purpose of the generator is to make the discriminator recognize the popular commodity images it generates as real, that is, it is impossible to distinguish that the image feature data input by the generator to the discriminator is fake.
[0099] Updating the quantum circuit parameter module:
[0100] The parameters in the generator and discriminator proposed in the present invention can be updated by the parameterized quantum circuit movement rules provided below.
[0101] First, a measurement operator The expected value under the parameterized quantum circuit U(θ i ) can be expressed as:
[0102]
[0103] Then, the gradient of the expected value function f(θ i ) with respect to the parameterized quantum circuit parameter θ i can be expressed as:
[0104]
[0105] The U(θ i ) in it can represent a parameterized quantum circuit that constitutes a generator or a discriminator, and θ i represents the parameter in U or P in the generator or discriminator. The above method is called the parameter shift rule for finding the analytical gradient of the parameterized quantum circuit with respect to the operator expectation value.
[0106] Through the parameter shift rule, the analytical gradients of the loss function shown in the previous module with respect to the generator and discriminator parameters can be obtained respectively. Then, the classical computer is used to update the parameters by the gradient descent method. Finally, by training the discriminator and the generator adversarially multiple times, the commodity image generation method based on the quantum generative adversarial neural network proposed by the present invention converges and stops, so that the trained generator of the present invention can be used to generate popular commodity image data.
[0107] As Figure 8 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 of the above commodity image generation methods based on the quantum generative adversarial neural network. Specifically:
[0108] The computer device 300 may vary greatly due to configuration or performance, and 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 of the commodity image generation methods 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 / output. The computer device 300 may also include other components for implementing the functions of the device, which will not be elaborated here.
[0109] 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 of the above commodity image generation methods based on the quantum generative adversarial neural network.
[0110] 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.
[0111] 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 commodity image generation methods based on the quantum generative adversarial neural network.
[0112] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, rather than to limit a specific order or sequence. The order of use of similar objects may be interchanged appropriately, so that the embodiments of the present application described herein can be implemented in an order other than the illustrated or described order.
[0113] 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 disclosure can be specifically implemented in the following forms: it can be completely hardware, can be completely 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.
[0114] 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 document, a 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.
[0115] 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 variations, modifications, substitutions, and alterations to the above embodiments within the scope of the present invention.
Claims
1. A method for generating commodity images based on a quantum generative adversarial neural network, characterized in that, Including: S1. Loading classical random noise as a quantum state; S2. Using a quantum generative neural network to operate on the quantum state to generate fake commodity image feature data, where the dimension of the fake commodity image feature data is the same as the dimension of the downsampled real commodity image data; S3. Inputting the fake commodity image feature data into the quantum discriminant neural network to obtain a first prediction result, and inputting the downsampled real commodity image data into the quantum discriminant neural network to obtain a second prediction result; Based on the basic quantum gate operations supported by a quantum computer, constructing the basic building blocks U and P of the quantum generative neural network and the quantum discriminant neural network. Based on multiple basic building blocks U acting between adjacent qubits, realizing quantum entanglement and quantum operations on classical random noise, measuring the Pauli-Z expectation of each qubit of the quantum generative neural network as the fake commodity image feature data, and based on multiple basic building blocks U and P, realizing the contraction of the quantum state characteristics of the quantum system and measuring the Pauli-Z expectation of the remaining qubits; S5. Combining the first prediction result and the second prediction result into a first loss function for training the quantum discriminant neural network, and updating the parameters of the quantum discriminant neural network according to the first loss function; S6. After the number of times of updating the parameters of the quantum discriminant neural network reaches a preset number threshold, inputting the fake commodity image feature data into the current quantum discriminant neural network to obtain a prediction result, 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 quantum discriminant neural network discriminates the fake commodity image feature data as real; S7. Returning to execute S1 until the latest obtained quantum discriminant neural network cannot determine whether it is fake commodity image feature data; S8. Using the latest obtained quantum generative neural network to generate commodity image data; Loading classical random noise as a quantum state includes: Loading classical random noise as a quantum state through an angle encoding method; Taking the arctangent of each element in the classical random noise to obtain the rotation angle of the quantum gate, and based on the rotation angle of the quantum gate, loading the classical random noise onto the amplitude of the quantum state by rotating the quantum gate to load the classical random noise as a quantum state.
2. The commodity image generation method based on a quantum generative adversarial neural network according to claim 1, wherein Updating the parameters of the quantum generative neural network according to the second loss function further includes: fixing the parameters of the current quantum discriminant neural network.
3. A method for generating product images based on a quantum generative adversarial neural network according to claim 1, characterized in that, The process of obtaining the downsampled real commodity image data includes: performing autoencoding on the real commodity image data according to the number of qubits used by the quantum generative neural network to obtain the downsampled real commodity image data.
4. A commodity image generation system based on a quantum generative adversarial neural network, characterized in that, Including a random noise quantum state encoding module, a training module, and a commodity image data generation module; The random noise quantum state encoding module is used to: load classical random noise as a quantum state; The training module is used to: operate on the quantum state using a quantum generative neural network to generate fake product image feature data, where the dimension of the fake product image feature data is the same as the dimension of the downsampled real product image data; input the fake product image feature data into the quantum discriminative neural network to obtain a first prediction result, and input the downsampled real product image data into the quantum 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 quantum discriminative neural network, and update the parameters of the quantum discriminative neural network according to the first loss function; when the number of times of updating the parameters of the quantum discriminative neural network reaches a preset number threshold, input the fake product image feature data into the current quantum discriminative neural network to obtain a prediction result, 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 quantum discriminative neural network discriminates the fake product image feature data as real; recall the random noise quantum state encoding module until the latest obtained quantum discriminative neural network cannot determine whether it is fake product image feature data; Based on the basic quantum gate operations supported by a quantum computer, construct the basic building blocks U and P of the quantum generative neural network and the quantum discriminative neural network. Based on multiple basic building blocks U acting between adjacent qubits, achieve quantum entanglement and quantum operations on classical random noise, measure the Pauli-Z expectation of each qubit of the quantum generative neural network as the fake product image feature data, and based on multiple basic building blocks U and P, achieve the contraction of the quantum state characteristics of the quantum system, and measure the Pauli-Z expectation of the remaining qubits; The product image data generation module is used to: generate product image data using the latest obtained quantum generative neural network; The random noise quantum state encoding module is specifically used to: load classical random noise as a quantum state through an angle encoding method; take the arctangent of each element in the classical random noise to obtain the rotation angle of the quantum gate, and based on the rotation angle of the quantum gate, load the classical random noise onto the amplitude of the quantum state by rotating the quantum gate, so as to load the classical random noise as a quantum state.
5. The commodity image generation system based on a quantum generative adversarial neural network according to claim 4, characterized in that, The training module is also specifically used to: fix the parameters of the current quantum discriminative neural network before updating the parameters of the quantum generative neural network according to the second loss function.
6. The commodity image generation system based on a quantum generative adversarial neural network according to claim 4, wherein It further includes a real product image data downsampling module, and the real product image data downsampling module is used to: perform autoencoding on the real product image data according to the number of qubits used by the quantum generative neural network to obtain the downsampled real product image data.
7. 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 so that the computer device implements a method for generating a commodity image based on a quantum generative adversarial neural network as described in any one of claims 1 to 3.
8. 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 so that a computer implements a method for generating a commodity image based on a quantum generative adversarial neural network as described in any one of claims 1 to 3.
Citation Information
Patent Citations
Quantum generative adversarial network algorithm based on conditional constraints
CN111814907A