Image classification method, device, medium and equipment based on distributed quantum computing
By normalizing and segmenting images, and quantum encoding and prototyping network training on distributed quantum computing nodes, the problem of low image classification efficiency in quantum computing is solved, and efficient training and high-accuracy image classification are achieved .
Patent Information
- Application Number
- CN202411406886.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-10
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2044-10-10
AI Technical Summary
The prior art is difficult to efficiently realize image classification in quantum computing, especially to quickly and accurately complete image classification tasks on distributed quantum computing nodes.
By performing normalized preprocessing and pixel segmentation of the classified image, it is allocated to multiple first quantum computing nodes for quantum encoding and efficient hardware profiling network evolution training processing, obtain the node output value and input it to the second quantum computing node for Further processing is made to obtain the image classification label prediction value.
Efficient training on distributed quantum computing nodes is achieved, which significantly reduces training time, has a classification accuracy of about 95%, and is easy to implement in physical experiments.
Smart Images

Figure CN118918395B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of quantum computing technology, and in particular to an image classification method, device, medium and equipment based on distributed quantum computing. Background Art
[0002] Quantum algorithm is an advanced computing method based on quantum mechanics. In particular, it uses quantum bits (Qubit) as the basic unit of information, and performs computing tasks with the help of characteristics such as quantum superposition and quantum entanglement. At present, quantum algorithms have shown unparalleled advantages over classical algorithms on some specific problems. For example, when dealing with the problem of prime factorization of large numbers, Shor's algorithm shows an exponential acceleration advantage compared to classical algorithms. In addition, when it comes to the problem of searching unordered databases, Grover's algorithm shows a quadratic acceleration effect compared to classical algorithms. They not only demonstrate the great potential of quantum algorithms in dealing with complex problems, but also pave a broad road for the future development of quantum computing.
[0003] Distributed quantum algorithms represent an innovative algorithm that combines distributed computing with quantum algorithms. The core idea is to decompose complex and large quantum algorithm tasks into a series of smaller and more manageable subtasks, which are assigned to multiple small quantum computers for parallel processing. This approach has obvious advantages over traditional centralized quantum algorithms because it greatly reduces the number of quantum bits and the depth of quantum circuits required for each computing node. This distributed design enables quantum computing tasks to be completed with higher efficiency and lower error rates, which is particularly suitable for the limitations of current quantum hardware technology. Summary of the invention
[0004] The purpose of the present invention is to provide an image classification method, device, medium and equipment based on distributed quantum computing, which are used to quickly and accurately implement image classification based on distributed quantum computing nodes.
[0005] According to one aspect of the present invention, there is provided an image classification method based on distributed quantum computing, comprising: performing normalization preprocessing on an image to be classified to obtain a normalized image with pixel values in the range of 0 to 1; performing pixel segmentation on the normalized image to obtain multiple pixel groups, and assigning a first quantum computing node to each pixel group; performing quantum encoding on the input pixel group at each first quantum computing node, executing evolutionary training processing based on a hardware-efficient simulated network, and obtaining a node output value according to the output quantum state of the hardware-efficient simulated network; obtaining the node output values of multiple first quantum computing nodes, inputting them into a second quantum computing node for quantum encoding, executing evolutionary training processing based on a hardware-efficient simulated network, and obtaining an image classification label prediction value according to the output quantum state of the hardware-efficient simulated network.
[0006] According to one embodiment of the present invention, the hardware efficient simulated network includes an input layer and multiple simulated layers connected in sequence, and the output of the previous simulated layer is used as the input of the next simulated layer, wherein the input end of the first simulated layer is connected to the output end of the input layer, and the input layer receives multiple quantum bits that have been quantum encoded, and the quantum encoding is phase angle encoding.
[0007] According to one embodiment of the present invention, the proposed layer includes single-qubit gates and multi-qubit gates, and the quantum circuit corresponding to each qubit includes a multi-qubit gate for generating entanglement with an adjacent qubit and at least one single-qubit gate.
[0008] According to one embodiment of the present invention, the multi-qubit gate is a CNOT gate, a CZ gate, a CY gate or a CH gate; the single-qubit gate is a RY gate, a RX gate or a RZ gate.
[0009] According to one embodiment of the present invention, obtaining the node output value based on the output quantum state of the hardware-efficient simulated network includes: obtaining the node output value based on the expected value of the Pauli operator Z of an output quantum state among multiple quantum bits.
[0010] According to one embodiment of the present invention, obtaining the image classification label prediction value based on the output quantum state of the hardware efficient simulated network includes: obtaining the image classification label prediction value based on the expected value of the Pauli operator Z of two output quantum states of multiple quantum bits.
[0011] According to one embodiment of the present invention, based on the predicted values and actual values of the classification labels of the images to be trained, multiple rounds of optimization training are performed on the hardware efficient simulated network on the first quantum computing node and the second quantum computing node through a classical optimizer.
[0012] According to another aspect of the present invention, there is provided an image classification device based on distributed quantum computing, comprising:
[0013] An image preprocessing unit is configured to perform normalization preprocessing on the image to be classified to obtain a normalized image with pixel values in the range of 0 to 1;
[0014] An image segmentation unit is configured to perform pixel segmentation on the normalized image to obtain a plurality of pixel groups, and allocate a first quantum computing node to each pixel group;
[0015] A first evolution unit is configured to perform quantum encoding on the input pixel group at each first quantum computing node, perform evolutionary training processing based on the hardware efficient simulated network, and obtain a node output value according to an output quantum state of the hardware efficient simulated network;
[0016] The second evolution unit is configured to obtain node output values of multiple first quantum computing nodes, input them into the second quantum computing node for quantum encoding, perform evolutionary training processing based on the hardware efficient simulated network, and obtain the image classification label prediction value according to the output quantum state of the hardware efficient simulated network.
[0017] According to another aspect of the present invention, there is provided an image classification system based on distributed quantum computing, comprising:
[0018] An image preprocessing unit is configured to perform normalization preprocessing on the image to be classified to obtain a normalized image with pixel values in the range of 0 to 1;
[0019] An image segmentation unit is configured to perform pixel segmentation on the normalized image to obtain a plurality of pixel groups, and allocate a first quantum computing node to each pixel group;
[0020] A plurality of distributed first quantum computing nodes, each of which is configured to perform quantum encoding on an input pixel group, perform evolutionary training processing based on a hardware efficient simulated network, and obtain a node output value according to an output quantum state of the hardware efficient simulated network;
[0021] The second quantum computing node is configured to perform quantum encoding on the node output values of the input multiple first quantum computing nodes, perform evolutionary training processing based on the hardware efficient simulated network, and obtain the image classification label prediction value according to the output quantum state of the hardware efficient simulated network.
[0022] According to another aspect of the present invention, a computer-readable storage medium storing a computer program is provided. When the computer program is executed by a processor, the image classification method based on distributed quantum computing as described above is implemented.
[0023] According to another aspect of the present invention, a computer device is provided, comprising: a processor; and a memory storing a computer program, wherein when the computer program is executed by the processor, the image classification method based on distributed quantum computing as described above is implemented.
[0024] Compared with the prior art, the present invention has the following beneficial effects:
[0025] (1) The distributed variational quantum algorithm based on data cutting can solve the image binary classification problem efficiently and meet the needs of the NISQ era.
[0026] (2) The image classification method based on distributed quantum computing can be implemented through quantum computing software (PyQPanda and VQNet). The results show that a classification accuracy of about 95% can be achieved.
[0027] (3) It can achieve efficient training, which greatly reduces the training time compared with existing technologies. A single round of training takes about 4 minutes, and training can be completed after 2 rounds of training (about 8 minutes), which means efficient training is achieved.
[0028] (4) Easy to implement in physical experiments. Using multiple distributed quantum computing nodes to execute quantum algorithms, a single computing node only needs to use 5 qubits at most, and the maximum quantum circuit depth of the node is only 17. Secondly, only single-qubit gates and CNOT gates between adjacent qubits need to be executed in the quantum circuit, without the need to execute multi-qubit gates.
[0029] The technical solution of the present invention greatly improves the efficiency of solving the image binary classification problem, and at the same time verifies the powerful ability of the combination of variational quantum algorithm and distributed quantum algorithm, which provides inspiration for how to use distributed variational quantum algorithm to solve other computing problems. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] The above objects and features of the present invention will become more clear through the following description in conjunction with the accompanying drawings.
[0031] Figure 1 Shown is a flow chart of a neural network training method for image classification based on distributed quantum computing according to an exemplary embodiment of the present invention.
[0032] Figure 2 Shown is a schematic diagram of a neural network training system for image classification based on distributed quantum computing according to an exemplary embodiment of the present invention.
[0033] Figure 3 Shown is a schematic diagram of a hardware efficient proposed HEA network according to an exemplary embodiment of the present invention.
[0034] Figure 4 Shown is a flow chart of an image classification method based on distributed quantum computing according to an exemplary embodiment of the present invention.
[0035] Figure 5 Shown is a schematic diagram of an image classification system based on distributed quantum computing according to an exemplary embodiment of the present invention.
[0036] Figure 6 Shown is a schematic diagram of pixel distribution of a sample image before segmentation according to an exemplary embodiment of the present invention.
[0037] Figure 7 Shown is a schematic diagram of pixel distribution after segmentation of a sample image according to an exemplary embodiment of the present invention.
[0038] Figure 8 Shown is a schematic diagram of a quantum circuit in which image pixels are encoded into quantum states according to an exemplary embodiment of the present invention.
[0039] Fig. 9 Shown is a schematic diagram of the HEA network structure on a first quantum computing node according to an exemplary embodiment of the present invention.
[0040] Fig.10 Shown is a schematic diagram of the HEA network structure on a second quantum computing node according to an exemplary embodiment of the present invention. DETAILED DESCRIPTION
[0041] Hereinafter, embodiments of the present invention will be described in detail with reference to the accompanying drawings.
[0042] like Figure 1 As shown, a neural network training method for image classification based on distributed quantum computing is given, including the following steps:
[0043] Step S101, performing normalization preprocessing on the image to be classified to obtain a normalized image with pixel values in the range of 0 to 1;
[0044] Step S102, performing pixel segmentation on the normalized image to obtain a plurality of pixel groups, and allocating a first quantum computing node to each pixel group;
[0045] Step S103, performing quantum encoding on the input pixel groups at each first quantum computing node, executing evolutionary training processing based on the hardware efficient simulated network, and obtaining the node output value according to the output quantum state of the hardware efficient simulated network;
[0046] Step S104, obtaining node output values of multiple first quantum computing nodes, inputting them into the second quantum computing node for quantum encoding, performing evolutionary training processing based on the hardware efficient simulated network, and obtaining image classification label prediction values according to the output quantum states of the hardware efficient simulated network;
[0047] Step S105, based on the predicted value and the actual value of the classification label of the image to be trained, multiple rounds of optimization training are performed on the hardware efficient simulated network on the first quantum computing node and the second quantum computing node through a classical optimizer.
[0048] like Figure 2 As shown, a schematic diagram of a neural network training system for image classification based on distributed quantum computing is given, including:
[0049] The image preprocessing unit 201 is configured to perform normalization preprocessing on the image to be classified to obtain a normalized image with pixel values in the range of 0 to 1;
[0050] The image segmentation unit 202 is configured to perform pixel segmentation on the normalized image to obtain a plurality of pixel groups, and allocate a first quantum computing node to each pixel group;
[0051] A plurality of distributed first quantum computing nodes 203, each of which is configured to perform quantum encoding on an input pixel group, perform evolutionary training processing based on a hardware efficient simulated network, and obtain a node output value according to an output quantum state of the hardware efficient simulated network;
[0052] The second quantum computing node 204 is configured to perform quantum encoding on the node output values of the input multiple first quantum computing nodes, perform evolutionary training processing based on the hardware efficient simulated network, and obtain the image classification label prediction value according to the output quantum state of the hardware efficient simulated network;
[0053] The optimizer 205 is used to perform multiple rounds of optimization training on the hardware efficient simulated network on the first quantum computing node and the second quantum computing node based on the predicted value and the actual value of the classification label of the image to be trained.
[0054] like Figure 3 As shown in the figure, a schematic diagram of a Hardware-Efficient Ansatz (HEA) network is given. The HEA network includes multiple layers of quantum circuits, each of which constitutes an ansatz layer. Each ansatz layer includes two parts: (1) arbitrary single-qubit gate operations, such as RY gates; (2) multi-qubit gate operations that produce quantum entanglement, such as CNOT gates.
[0055] By using the Hardware-Efficient Ansatz (HEA) network configured on the first quantum computing node and the second quantum computing node as a training quantum circuit, neural network training for image classification can be realized. The network parameters in the HEA network are optimized and trained in combination with the optimizer. Finally, when the classification prediction value meets the classification requirements, the network parameters in the HEA network at this time are fixed in the HEA network as the final parameters. At this time, the HEA network can be used as an image classification neural network on the quantum computing node to perform classification prediction on the input image and finally output the classification label prediction result.
[0056] Based on the trained hardware-efficient ansatz (HEA) network, it can be deployed on quantum computing nodes to perform Figure 4 The image classification method based on distributed quantum computing shown includes the following steps:
[0057] Step S401, performing normalization preprocessing on the image to be classified to obtain a normalized image with pixel values in the range of 0 to 1;
[0058] Step S402, performing pixel segmentation on the normalized image to obtain a plurality of pixel groups, and allocating a first quantum computing node to each pixel group;
[0059] Step S403, performing quantum encoding on the input pixel groups at each first quantum computing node, executing evolutionary training processing based on the hardware efficient simulated network, and obtaining the node output value according to the output quantum state of the hardware efficient simulated network;
[0060] Step S404, obtaining node output values of multiple first quantum computing nodes, inputting them into the second quantum computing node for quantum encoding, executing evolutionary training processing based on the hardware efficient simulated network, and obtaining the image classification label prediction value according to the output quantum state of the hardware efficient simulated network.
[0061] Corresponding to the image classification method based on distributed quantum computing, the image classification device based on distributed quantum computing includes:
[0062] An image preprocessing unit is configured to perform normalization preprocessing on the image to be classified to obtain a normalized image with pixel values in the range of 0 to 1;
[0063] An image segmentation unit is configured to perform pixel segmentation on the normalized image to obtain a plurality of pixel groups, and allocate a first quantum computing node to each pixel group;
[0064] A first evolution unit is configured to perform quantum encoding on the input pixel group at each first quantum computing node, perform evolutionary training processing based on the hardware efficient simulated network, and obtain a node output value according to an output quantum state of the hardware efficient simulated network;
[0065] The second evolution unit is configured to obtain node output values of multiple first quantum computing nodes, input them into the second quantum computing node for quantum encoding, perform evolutionary training processing based on the hardware efficient simulated network, and obtain the image classification label prediction value according to the output quantum state of the hardware efficient simulated network.
[0066] like Figure 5 As shown, a schematic diagram of an image classification system based on distributed quantum computing is given, including:
[0067] The image preprocessing unit 201 is configured to perform normalization preprocessing on the image to be classified to obtain a normalized image with pixel values in the range of 0 to 1;
[0068] The image segmentation unit 202 is configured to perform pixel segmentation on the normalized image to obtain a plurality of pixel groups, and allocate a first quantum computing node to each pixel group;
[0069] A plurality of distributed first quantum computing nodes 203, each of which is configured to perform quantum encoding on an input pixel group, perform evolutionary training processing based on a hardware efficient simulated network, and obtain a node output value according to an output quantum state of the hardware efficient simulated network;
[0070] The second quantum computing node 204 is configured to perform quantum encoding on the node output values of the input multiple first quantum computing nodes, perform evolutionary training processing based on the hardware efficient simulated network, and obtain the image classification label prediction value according to the output quantum state of the hardware efficient simulated network.
[0071] In the above system, the distributed first-stage image classification prediction is realized by allocating image segmentation data to different first quantum computing nodes, and the node output value is obtained based on the HEA network. The node output value of the first quantum computing node is aggregated to the second quantum computing node, and the input node output value is further evolved at the second quantum computing node based on the hardware efficient simulated network, and the image classification label prediction value is obtained according to the output quantum state of the HEA network.
[0072] The hardware efficient simulated network includes an input layer and multiple simulated layers connected in sequence, the output of the previous simulated layer is used as the input of the next simulated layer, wherein the input end of the first simulated layer is connected to the output end of the input layer, and the input layer receives multiple quantum bits that have been quantum-encoded, and the quantum coding is phase angle coding. The simulated layer includes a single-qubit gate and a multi-qubit gate, and the quantum circuit corresponding to each qubit includes a multi-qubit gate for generating entanglement with adjacent qubits and at least one single-qubit gate. The multi-qubit gate is a CNOT gate, a CZ gate, a CY gate, or a CH gate; the single-qubit gate is a RY gate, an RX gate, or an RZ gate.
[0073] The method of obtaining the node output value according to the output quantum state of the hardware efficient simulated network includes: obtaining the node output value according to the Pauli operator expectation value Z obtained from one quantum state of the multiple quantum bits. The method of obtaining the image classification label prediction value according to the output quantum state of the hardware efficient simulated network includes: obtaining the image classification label prediction value according to the Pauli operator expectation value obtained from two quantum states of the multiple quantum bits.
[0074] Example 1: Image binary classification training process
[0075] The binary image classification problem is a common problem in classical machine learning. This embodiment uses distributed quantum computing to implement binary image classification. The data set of this embodiment is two handwritten numbers selected from MNIST, such as 3 and 6. The training set contains 5000 samples and the test set contains 1000 samples. Each data sample is a 5x5 two-dimensional array type, and the value range of the array element is an integer between [0, 255]. Each sample label [0. 1.] represents the number 6, and the label [1. 0.] represents the number 3. It is limited that each pixel in the data sample must be encoded using a quantum bit.
[0076] Step 601: Data preprocessing
[0077] For the given MNIST data set, necessary normalization preprocessing is performed: including randomization and normalization.
[0078] Randomization processing includes: randomly shuffling the data set so that the trained model can better generalize samples that it has not encountered before, thereby improving the effect of the optimization algorithm;
[0079] The normalization process includes: normalizing the data, dividing each pixel in the sample data by 255, converting it into a floating point number between [0, 1], and obtaining normalized image data.
[0080] Step 602: Data segmentation
[0081] Each data sample in the data set is a 5*5 two-dimensional array, and the pixel value of the normalized image data is represented by α i To indicate that α i Represents the i-th pixel value in the normalized image data. For a 5*5 two-dimensional array, i is a natural number ranging from 1 to 25. Figure 6 As shown, an exemplary schematic diagram of pixel distribution before image segmentation is given.
[0082] In this embodiment, data segmentation is performed on 25 pixels of the normalized image data, that is, the data is segmented into 5 groups, for example: Figure 7 As shown in Figure 1, an exemplary pixel distribution diagram after image segmentation is given. Figure 7 In , the image is divided into 5 groups by row, namely the 1st to 5th, 6th to 10th, 11th to 15th, 16th to 20th, and 21st to 25th pixels, and 5 computing nodes are used to encode the 5 groups of pixels respectively. Similarly, the data segmentation of the normalized image data can also be performed by column segmentation to obtain grouped data.
[0083] Step 603: Quantum state encoding representation
[0084] Reference Figure 2As shown, the pixel grouping data is distributed to multiple distributed first quantum computing nodes, each of which has 5 quantum bits. One quantum bit is allocated to each pixel to realize quantum encoding of the pixel data. The encoding method adopted is angle encoding. The RY gate is selected as the rotation gate to convert the normalized pixel value α i Substituting it into the RY gate realizes the quantum state encoding of the pixel value.
[0085] Take the first set of pixel data α 1 To α 5 For example, Figure 8 As shown, in the first quantum computing node allocated for pixel grouping, 5 quantum bits with the initial quantum state of |0> are allocated, and the RY gate is applied to each quantum bit to rotate with the corresponding pixel value as the angle value θ to realize phase angle encoding, where the matrix of the RY gate is expressed as:
[0086] On each first quantum computing node, quantum encoding of pixel data can be implemented for the corresponding pixel group data in the above manner.
[0087] Step 604: Distributed quantum training
[0088] like Fig. 9 As shown, the hardware-efficient ansatz (HEA) network includes an input layer and multiple ansatz layers, wherein the input layer includes a 5-qubit RY θ1 Door to RY θ5 The proposed layer is 3 layers, and the 3 proposed layers are connected in sequence. The output of the previous proposed layer is used as the input of the next proposed layer. Among them, the input of the first proposed layer is the input layer RY θ1 Door to RY θ5 In each hypothetical layer, each quantum circuit includes a CNOT gate and an RY gate. The CNOT gate generates quantum entanglement between adjacent quantum bits, and each quantum circuit is configured with an RY gate, that is, p_1 Door to RY p_5 In the hardware efficient anatomy (HEA) network, the parameters need to be determined through training as the values of the phase angle θ in the input layer and the three anatomy layers, for example, θ 1 to θ 5 ,θ p_1 to θ p_5 .
[0089] For the node output value of the first quantum computing node, the expected value of the quantum terminal outputted by the last hypothetical layer (number of layers p=3, i.e., the third hypothetical layer) of the hardware efficient hypothetical (HEA) network with respect to the Pauli operator Z is used as the node output value. For the five quantum bits of the third hypothetical layer, the quantum state of one of the quantum bits is selected, and the expected value of the Pauli operator Z is obtained according to the selected output quantum state as the node output value of the first quantum computing node. Preferably, the quantum state of the last quantum bit in the third hypothetical layer to which a multi-qubit gate is applied is selected to obtain the expected value of the Pauli operator Z. Fig. 9 , select RY p_5 The quantum state of the gate is used to obtain the expected value of the Pauli operator Z as the node output value of the first quantum computing node. The multi-qubit gate is a CNOT gate. The quantum state of the fifth qubit that is the last to be subjected to the CNOT gate is selected to obtain the expected value Z of the Pauli operator Z. 5 By analogy, we can get the node output values of the other four first quantum computing nodes as Z 10 , Z 15 , Z 20 , Z 25 It should be noted that the expected values of the Pauli operator Z of the five first quantum computing nodes can be obtained by independent parallel calculations of five quantum computers, and this process can be regarded as the process of implementing calculations using a distributed quantum algorithm.
[0090] Step 605: Summarize the node output values after distributed quantum node network training
[0091] like Fig.10 As shown, the output value Z of the 5 first quantum computing nodes 5 , Z 10 , Z 15 , Z 20 , Z 25 As a classical data value input to the second quantum computing node, first use the RY gate to Z 5 , Z 10 , Z 15 , Z 20 , Z 25 Convert angle encoding into quantum state.
[0092] The Hardware-Efficient Ansatz (HEA) network includes an input layer and multiple ansatz layers. The input layer includes a 5-qubit RY gate. The ansatz layers are 3 layers, which are connected sequentially. The output of the previous ansatz layer is used as the input of the next ansatz layer. The input of the first ansatz layer is the quantum state of the input layer. The parameters that need to be determined through training in the Hardware-Efficient Ansatz (HEA) network are the phase angle θ values of the input layer and the RY gates in the 3 ansatz layers, for example, β1 To β 5 , β p_1 To β p_5 In each hypothetical layer, each quantum circuit includes a CNOT gate and a RY gate.
[0093] According to the quantum state of the last hypothetical layer in the hardware efficient hypothetical (HEA) network, the output value of the second quantum computing node can be obtained, that is, the image classification label prediction value. For example, the quantum state of the 4th and 5th quantum bits in the third hypothetical layer is obtained, and the expected value of the Pauli operator Z is obtained according to these two quantum bits, Z_2_4 and Z_2_5. If Z_2_4 >Z_2_5, then it means that the final classification label prediction value is [1, 0], indicating the image number 3, otherwise, it is [0,1], indicating the image number 6.
[0094] Step 606: Network parameter optimization training
[0095] According to the actual labels of the sample data and the predicted labels of the training output, a classical optimizer (such as an Adam optimizer or a BFGS optimizer) is further used to optimize all parameters (i.e., θ and β) of the quantum neural network in the first quantum computing nodes and the second quantum computing nodes, and a set of new θ' and β' parameters are returned. The quantum neural network is a hardware efficient analog (HEA) network.
[0096] Step 607: Iterative training
[0097] Based on the returned set of new θ' and β' parameters, the above steps are repeated for each training sample until the error between the actual label and the predicted label of the training output converges to the set threshold. Finally, a quantum neural network or parameterized quantum circuit with fixed parameters θ and β is obtained.
[0098] Step 608: Determine the classification accuracy using the test set
[0099] By applying the finally trained parameterized quantum circuit to the data samples in the test set, all label results can be counted and the final classification accuracy can be output.
[0100] Specifically, when the image classification process is actually executed, the corresponding quantum gate operations are built in the quantum computing software (PyQPanda and VQNet) according to the above steps, and the quantum-classical hybrid neural network is constructed, wherein the number of quantum bits of the first and second quantum computing nodes is set to 5. In the final quantum circuit, the maximum number of quantum gates of the node is 37, and the maximum quantum circuit depth of the node is 17. In the process of training 5,000 training samples, a single round of training takes about 4 minutes, and the training can be completed after 2 rounds of training, which takes about 8 minutes. Finally, 1,000 test samples are classified through the parameterized quantum circuit after the above training, and it is finally found that the classification accuracy is about 95%.
[0101] In contrast, if a 25-qubit quantum neural network is used to train an image with 25 pixel values on a single quantum computing node according to the existing method, a single round of training takes more than 24 hours. It can be seen that the image classification training method of this embodiment can not only achieve a classification accuracy of 95%, but also significantly reduce the time required for training. At the same time, the number of quantum gates required and the depth of quantum circuits are also significantly reduced, which is more conducive to physical realization.
[0102] Example 2: Image multi-classification training process.
[0103] Based on the binary classification training process of the image in Example 1, the binary classification training method can be executed multiple times to expand the scale of the distributed quantum computing nodes and the data transmission relationship, thereby realizing the multi-classification training process of the image.
[0104] Example 3: Image binary classification process based on distributed quantum computing.
[0105] The binary image classification problem is a common problem in classical machine learning. This embodiment attempts to implement binary image classification using a distributed quantum algorithm. The data set of this embodiment is two handwritten numbers selected from MNIST, such as 3 and 6. The test set contains 1000 samples. Each data sample is a 5x5 two-dimensional array type, and the value range of the array element is an integer between [0, 255]. Each sample label [1. 0.] represents the number 3, and the label [0. 1.] represents the number 6. It is limited that each pixel in the data sample must be encoded using a quantum bit.
[0106] Step 701: Data preprocessing.
[0107] For the given MNIST data set, necessary normalization preprocessing is performed: including randomization and normalization.
[0108] Randomization processing includes: randomly shuffling the data set so that the trained model can better generalize samples that it has not encountered before, thereby improving the effect of the optimization algorithm;
[0109] The normalization process includes: normalizing the data, dividing each pixel in the sample data by 255, converting it into a floating point number between [0, 1], and obtaining normalized image data.
[0110] Step 702: Data segmentation and grouping
[0111] Each data sample in the data set is a 5*5 two-dimensional array, and the pixel value of the normalized image data is represented by α i To express, α i Represents the i-th pixel value in the normalized image data. For a 5*5 two-dimensional array, i is a natural number ranging from 1 to 25. Figure 6 As shown, an exemplary schematic diagram of pixel distribution before image segmentation is given.
[0112] In this embodiment, data segmentation is performed on 25 pixels of the normalized image data, that is, the data is segmented into 5 groups, for example: Figure 7 As shown in Figure 1, an exemplary pixel distribution diagram after image segmentation is given. Figure 7 In , the image is divided into 5 groups by row, namely the 1st to 5th, 6th to 10th, 11th to 15th, 16th to 20th, and 21st to 25th pixels, and 5 computing nodes are used to encode the 5 groups of pixels respectively. Similarly, the data segmentation of the normalized image data can also be performed by column segmentation to obtain grouped data.
[0113] Step 703: Quantum state encoding representation
[0114] The pixel grouping data is assigned to the distributed first quantum computing node. Each first quantum computing node has 5 quantum bits. One quantum bit is assigned to each pixel to realize quantum encoding of the pixel data. The encoding method adopted is angle encoding. The RY gate is selected as the rotation gate to convert the normalized pixel value α i Substituting it into the RY gate realizes the quantum state encoding of the pixel value.
[0115] Take the first set of pixel data α 1 To α 5 For example, Figure 8 As shown, in the first quantum computing node allocated for pixel grouping, 5 quantum bits with the initial quantum state of |0> are allocated, and the RY gate is applied to each quantum bit to rotate with the corresponding pixel value as the angle value θ to achieve phase angle encoding, where the matrix of the RY gate is expressed as:
[0116] On each first quantum computing node, quantum encoding of pixel data can be implemented in the above manner.
[0117] Step 704: Distributed quantum node quantum computing processing
[0118] like Fig. 9 As shown, the Hardware-Efficient Ansatz (HEA) network includes an input layer and multiple ansatz layers, the input layer includes a 5-qubit RY gate, the ansatz layers are 3 layers, the 3 ansatz layers are sequentially connected, the output of the previous ansatz layer is used as the input of the next ansatz layer, and the input of the first ansatz layer is the quantum state of the input layer. In the Hardware-Efficient Ansatz (HEA) network, the parameters that need to be determined through training are the values of the phase angle θ in the input layer and the 3 ansatz layers, for example, θ 1 to θ 5 ,θ p_1 to θ p_5 In each hypothetical layer, each quantum circuit includes a CNOT gate and a RY gate.
[0119] For the node output value of the first quantum computing node, the expectation value of the Pauli operator Z of the quantum state of the last hypothetical layer (i.e., the third hypothetical layer) of the hardware efficient hypothetical (HEA) network is used as the node output value. For the five quantum bits of the third hypothetical layer, the quantum state of one of the quantum bits is selected, and the expectation value of the Pauli operator Z is obtained according to the selected quantum state as the node output value of the first quantum computing node. Preferably, the quantum state of the last quantum bit in the third hypothetical layer to which a multi-qubit gate is applied is selected to obtain the expectation value of the Pauli operator Z.
[0120] For example, if the multi-qubit gate is a CNOT gate, the quantum state of the fifth qubit to which the CNOT gate is applied is selected to obtain the expectation value Z of the Pauli operator Z. 5 By analogy, we can get the node output values of the other four first quantum computing nodes as Z 10 , Z 15 , Z 20 , Z 25 It should be noted that the expected value of the Pauli operator Z of the five first quantum computing nodes can be obtained through parallel calculations on five quantum computers, and this process can be regarded as the process of implementing calculations using a distributed quantum algorithm.
[0121] Step 705: Summarize the node output values of the distributed quantum nodes
[0122] like Fig.10 As shown, the Z output by the five first quantum computing nodes 5 , Z 10 , Z 15 , Z 20 , Z 25 As a classical data value input to the second quantum computing node, first use the RY gate to Z5 , Z 10 , Z 15 , Z 20 , Z 25 The angle encoding is converted into a quantum state.
[0123] The Hardware-Efficient Ansatz (HEA) network includes an input layer and multiple ansatz layers, wherein the input layer includes a 5-qubit RY gate, and the ansatz layers are 3 layers, which are sequentially connected, and the output of the previous ansatz layer is used as the input of the next ansatz layer, wherein the input of the first ansatz layer is the quantum state of the input layer. The parameters that need to be determined through training in the Hardware-Efficient Ansatz (HEA) network are the phase angle θ values of the input layer and the RY gates in the 3 ansatz layers, for example, β 1 To β 5 , β p_1 To β p_5 In each hypothetical layer, each quantum circuit includes a CNOT gate and a RY gate.
[0124] According to the quantum state of the last hypothetical layer in the hardware efficient hypothetical (HEA) network, the output value of the second quantum computing node can be obtained, that is, the classification label prediction value. For example, the quantum states of the 4th and 5th quantum bits in the third hypothetical layer are obtained, and the expected value of the Pauli operator Z is obtained according to the quantum states of these two quantum bits: Z_2_4 and Z_2_5. If Z_2_4> Z_2_5, then it means that the final classification label prediction value is [1, 0], indicating image 3, otherwise, it is [0, 1], indicating image 6.
[0125] The image classification method based on distributed quantum computing of the present invention can solve the image binary classification problem based on the distributed variational quantum algorithm of data cutting, and can efficiently solve the above image binary classification problem, which meets the needs of the NISQ era. The image classification method based on distributed quantum computing can be specifically implemented through quantum computing software (PyQPanda and VQNet). The results show that about 95% of the classification accuracy can be achieved, and efficient training can be achieved, which greatly reduces the training time compared with the existing technology. The training time for a single round is about 4 minutes, and the training can be completed after 2 rounds of training (about 8 minutes), that is, efficient training is achieved. If the traditional scheme is adopted, a quantum neural network with 25 quantum bits is used for training, and the training time for a single round exceeds 24 hours. Using distributed multiple quantum computing nodes to execute quantum algorithms, a single computing node only needs to use 5 quantum bits at most, and the maximum quantum circuit depth of the node is only 17. Secondly, only single quantum bit gates and CNOT gates between adjacent quantum bits need to be executed in the quantum circuit, and there is no need to execute multi-qubit gates, which makes the scheme easier to implement in physical experiments.
[0126] The technical solution of the present invention greatly improves the efficiency of solving the image binary classification problem, and at the same time verifies the powerful ability of the combination of variational quantum algorithm and distributed quantum algorithm, which provides inspiration for how to use distributed variational quantum algorithm to solve other computing problems.
[0127] In addition, a computer-readable storage medium storing a computer program may also be provided according to an exemplary embodiment of the present invention. The computer-readable storage medium stores a computer program that, when executed by a processor, causes the processor to perform an image classification method based on distributed quantum computing according to an exemplary embodiment of the present invention. The computer-readable recording medium is any data storage device that can store data read out by a computer system. Examples of computer-readable recording media include: read-only memory, random access memory, read-only optical disk, magnetic tape, floppy disk, optical data storage device, and carrier wave (such as data transmission through the Internet via a wired or wireless transmission path).
[0128] In addition, a computing device may be provided according to an exemplary embodiment of the present invention. The computing device includes a processor and a memory. The memory is used to store a computer program. The computer program is executed by the processor so that the processor executes the computer program of the image classification method based on distributed quantum computing according to an exemplary embodiment of the present invention.
[0129] It should be noted that the first, second, third, fourth, etc. in the above description are to distinguish features with the same name in the same or different embodiments, and are not quantitatively limited. And the present invention is not limited to the specific configurations and processes described above or shown in the figures. The above is only a specific embodiment of the present invention. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the described system, device, module or unit can refer to the corresponding process in the method embodiment without further description. It should be understood that the scope of protection of the present invention is not limited to this. Any technician familiar with the technical field can think of various equivalent modifications or substitutions within the technical scope disclosed by the present invention, and these modifications or substitutions should be covered within the scope of protection of the present invention.
Claims
1. An image classification method based on distributed quantum computing, characterized in that: include: Performing normalization preprocessing on the image to be classified to obtain a normalized image with pixel values ranging from 0 to 1; Performing pixel segmentation on the normalized image to obtain a plurality of pixel groups, and assigning a first quantum computing node to each pixel group; At each first quantum computing node, quantum encoding is performed on the input pixel group, and an evolutionary training process based on the hardware efficient simulated network is performed, and a node output value is obtained according to the output quantum state of the hardware efficient simulated network; Obtain node output values of multiple first quantum computing nodes, input them into the second quantum computing node for quantum encoding, perform evolutionary training processing based on the hardware efficient simulated network, and obtain image classification label prediction values according to the output quantum states of the hardware efficient simulated network. in, The hardware efficient pseudo network comprises an input layer and multiple pseudo layers connected in sequence, wherein the output of the previous pseudo layer is used as the input of the next pseudo layer, wherein the input end of the first pseudo layer is connected to the output end of the input layer, and the input layer receives multiple quantum bits that are quantum-encoded, and the quantum code is phase angle coding. The proposed layer includes a single-qubit gate and a multi-qubit gate, and the quantum circuit corresponding to each qubit includes a multi-qubit gate for generating entanglement with an adjacent qubit and at least one single-qubit gate, The method of obtaining a node output value according to the output quantum state of the hardware efficient simulated network includes: obtaining the node output value according to the expected value of an output quantum state of a plurality of quantum bits with respect to the Pauli operator Z, The method of obtaining the image classification label prediction value based on the output quantum state of the hardware efficient simulated network includes: obtaining the image classification label prediction value based on the expected value of the Pauli operator Z of two output quantum states of multiple quantum bits.
2. The method according to claim 1, characterized in that The multi-qubit gate is a CNOT gate, a CZ gate, a CY gate or a CH gate; The single quantum bit gate is an RY gate, an RX gate or an RZ gate.
3. The method according to claim 1, characterized in that Also includes: Based on the predicted values and actual values of the classification labels of the images to be trained, multiple rounds of optimization training are performed on the hardware efficient simulated network on the first quantum computing node and the second quantum computing node through a classical optimizer.
4. An image classification device based on distributed quantum computing, characterized in that: include: An image preprocessing unit is configured to perform normalization preprocessing on the image to be classified to obtain a normalized image with pixel values in the range of 0 to 1; An image segmentation unit is configured to perform pixel segmentation on the normalized image to obtain a plurality of pixel groups, and allocate a first quantum computing node to each pixel group; A first evolution unit is deployed in a plurality of first quantum computing nodes, each of which is configured to perform quantum encoding on an input pixel group, perform evolutionary training processing based on a hardware efficient simulated network, and obtain a node output value according to an output quantum state of the hardware efficient simulated network; The second evolution unit is deployed in the second quantum computing node, and the second quantum computing node is configured to perform quantum encoding on the node output values of the input multiple first quantum computing nodes, perform evolutionary training processing based on the hardware efficient simulated network, and obtain the image classification label prediction value according to the output quantum state of the hardware efficient simulated network. in, The hardware efficient pseudo network comprises an input layer and multiple pseudo layers connected in sequence, wherein the output of the previous pseudo layer is used as the input of the next pseudo layer, wherein the input end of the first pseudo layer is connected to the output end of the input layer, and the input layer receives multiple quantum bits that are quantum-encoded, and the quantum code is phase angle coding. The proposed layer includes a single-qubit gate and a multi-qubit gate, and the quantum circuit corresponding to each qubit includes a multi-qubit gate for generating entanglement with an adjacent qubit and at least one single-qubit gate, The first quantum computing node is further configured to obtain a node output value according to an expectation value of an output quantum state of the plurality of quantum bits with respect to the Pauli operator Z, The second quantum computing node is further configured to obtain an image classification label prediction value based on the expectation value of two output quantum states in the multiple quantum bits with respect to the Pauli operator Z.
5. An image classification system based on distributed quantum computing, characterized in that: include: An image preprocessing unit is configured to perform normalization preprocessing on the image to be classified to obtain a normalized image with pixel values in the range of 0 to 1; An image segmentation unit is configured to perform pixel segmentation on the normalized image to obtain a plurality of pixel groups, and allocate a first quantum computing node to each pixel group; A plurality of distributed first quantum computing nodes, each of which is configured to perform quantum encoding on an input pixel group, perform evolutionary training processing based on a hardware efficient simulated network, and obtain a node output value according to an output quantum state of the hardware efficient simulated network; The second quantum computing node is configured to quantum encode the node output values of the input multiple first quantum computing nodes, perform evolutionary training processing based on the hardware efficient simulated network, and obtain the image classification label prediction value according to the output quantum state of the hardware efficient simulated network. in, The hardware efficient pseudo network comprises an input layer and multiple pseudo layers connected in sequence, wherein the output of the previous pseudo layer is used as the input of the next pseudo layer, wherein the input end of the first pseudo layer is connected to the output end of the input layer, and the input layer receives multiple quantum bits that are quantum-encoded, and the quantum code is phase angle coding. The proposed layer includes a single-qubit gate and a multi-qubit gate, and the quantum circuit corresponding to each qubit includes a multi-qubit gate for generating entanglement with an adjacent qubit and at least one single-qubit gate, The first quantum computing node is further configured to obtain a node output value according to an expectation value of an output quantum state of the plurality of quantum bits with respect to the Pauli operator Z, The second quantum computing node is further configured to obtain an image classification label prediction value based on the expectation value of two output quantum states in the multiple quantum bits with respect to the Pauli operator Z.
6. A computer-readable storage medium storing a computer program, wherein: When the computer program is executed by a processor, the image classification method based on distributed quantum computing according to any one of claims 1 to 3 is implemented.
7. A computing device comprising: processor; A memory storing a computer program, which, when executed by a processor, implements the image classification method based on distributed quantum computing as described in any one of claims 1 to 3.
Citation Information
Patent Citations
Image classification method and system, electronic equipment and storage medium
CN117437494A