Evolutionary quantum neural network architecture search method based on quantum simulator
Searching for quantum neural network structures through quantum evolution algorithms solves the problem that the quantum neural network architecture search method in the existing technology cannot utilize quantum parallel characteristics and low image classification accuracy, and achieves higher classification accuracy and lower complexity. Suitable for deployment in quantum computing environments.
Patent Information
- Application Number
- CN202210362448.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-07
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2042-04-07
AI Technical Summary
The existing quantum neural network architecture search methods cannot fully utilize the quantum parallel characteristics, resulting in difficulty in deploying on quantum simulators or real quantum computers, and low image classification accuracy and high model complexity, and lack effective design methods for quantum neural networks.
Quantum evolution algorithm (QEA) is used to search quantum neural network architecture, and through Qubit-Lattice encoding and quantum logic gate design, quantum neural network structure is automatically searched using quantum superposition and entanglement characteristics to reduce line complexity and improve image classification accuracy.
It achieves higher image classification accuracy and lower quantum neural network complexity, which can be effectively deployed in quantum computing devices, making full use of the advantages of quantum parallel computing, and reducing time complexity.
Smart Images

Figure CN114676837B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of quantum computing technology, and in particular relates to an evolutionary quantum neural network architecture search method, which can be used for image classification. Background Art
[0002] A quantum simulator is a simulation of a quantum computer implemented on a classical computer. In a quantum simulator, quantum bits, quantum circuits, and quantum environments will all simulate real quantum computers. In order to make it easier for researchers to study and design quantum algorithms, many companies and institutions have designed and developed a large number of quantum simulators, and Cirq developed by Google is one of them. Cirq provides users with a large number of quantum logic gate interfaces and methods for operating quantum bits, allowing users to accurately control quantum circuits and build quantum neural networks. TensorFlow Quantum (TFQ) is an open source software framework developed by Google researchers for the design of quantum machine learning algorithms in Python. TFQ is designed to solve quantum machine learning problems in the NISQ era. It brings quantum computing primitives such as building quantum circuits into the TensorFlow ecosystem. In addition, it also provides tools to combine quantum algorithms and logic designed in Cirq with the TensorFlow framework.
[0003] Quantum neural network QNN, as a combination of quantum computing and neural network, is a cutting-edge technology in the development of artificial neural network theory. The efficient parallel computing of quantum and the approximation ability of neural network structure can form a more efficient and universal information processing method. Quantum neural network provides a new and efficient computing paradigm for solving pattern recognition and image classification problems. Most of the existing quantum neural networks are constructed in the form of quantum circuits in quantum simulators. The performance of quantum neural networks depends on the structure of quantum neural networks. The feature extraction capability brought by excellent quantum neural network architecture is the key factor to improve model performance. Therefore, what kind of quantum neural network structure to design and how to design the quantum neural network structure are the key points and difficulties of neural network design.
[0004] The design of existing neural network structures is mainly divided into manual design methods and traditional neural network architecture search methods. Manually designed neural network architectures often rely on a lot of manual experience as guidance, such as LeNet, AlexNet, ResNet, DenseNet, etc. With the continuous development of deep learning, the network scale of deep neural networks continues to increase, the increasing depth and even width, and the unexplainable feature extraction and reasoning process inside the network model make it difficult to manually design excellent neural network structures and have great limitations. Research on the manual design of quantum neural networks is relatively lagging. In 2018, Google's Farhi et al. proposed a general quantum neural network framework, but for such a quantum neural network framework, no other design ideas and methods for specific structures of quantum neural networks were given. There is no clear guiding experience for the circuit design of quantum neural networks, and the method of manually designing quantum neural networks is even more helpless. The existing quantum neural networks based on manual design have low image classification accuracy and high model complexity, which makes it difficult to deploy on quantum simulators or real quantum computers.
[0005] Neural network architecture search NAS aims to use effective search strategies to search for network structures in a certain search space, and to evaluate the performance of the currently searched neural network with appropriate evaluation strategies. Traditional neural network architecture search methods can be roughly divided into three search strategies based on reinforcement learning, evolution, and gradient according to different search strategies. Reinforcement learning-based and evolution-based methods can search for more effective network architectures that are different from manually designed ones, but at the same time have higher time costs. Gradient-based methods use gradient descent optimization strategies to reduce the time overhead of searching, but are more likely to fall into local optimality. For quantum neural network neural architecture search, traditional neural network architecture search methods cannot fully utilize the parallel characteristics of quantum, cannot be fully run in quantum simulators or quantum circuits, and therefore cannot be fully transplanted to quantum computers. Secondly, the population diversity and convergence of evolution-based neural network architecture search methods cannot be guaranteed in the later stage of population iteration, and the local search capability is insufficient. In addition, since quantum neural networks are still in the exploratory stage and do not have a unified and recognized structure, there are no architecture search methods and related theories for quantum neural networks. Summary of the invention
[0006] The purpose of the present invention is to address the deficiencies of the above-mentioned prior art and propose an evolutionary quantum neural network architecture search method based on a quantum simulator to improve the search capability, reduce the circuit complexity of the quantum neural network, and improve the image classification accuracy of the quantum neural network.
[0007] The technical solution of the present invention is achieved in this way:
[0008] 1. Technical Principle
[0009] The theoretical basis of the quantum neural network architecture search method proposed in the present invention is the evolutionary algorithm and the quantum evolutionary algorithm, which are briefly introduced below.
[0010] Evolutionary algorithm (EA) is a type of intelligent computing method proposed by researchers to solve optimization problems based on the biological evolution process and mechanism in nature. This algorithm is based on Mendel's theory of genetic variation and Darwin's theory of natural selection, and uses the biological model of population and individual evolution to heuristically search for the optimal solution. This type of algorithm usually uses a certain code to express complex structures, and each individual coding sequence is called an individual. The set of coding sequences formed by multiple individuals is called a population, and biological operations such as crossover, mutation, and selection are performed on the population to continuously iterate and update the optimal individual.
[0011] The quantum evolutionary algorithm (QEA) combines quantum theory with the characteristics of evolutionary algorithms, and fully utilizes the superposition and entanglement characteristics of quantum states in quantum computing to provide a new paradigm for data expression and computing methods. Since quantum bit chromosomes can represent superposition states, quantum evolutionary algorithms have better population diversity and good convergence. In theory, they can be deployed in increasingly complex quantum computing devices, making full use of the parallel computing capabilities of quantum systems, so that quantum neural structure search algorithms can run completely in the quantum circuits of quantum devices.
[0012] 2. Based on the above principles, the technical solutions of the present invention include the following:
[0013] (1) Use Qubit-Lattice encoding to quantize image data:
[0014] (1a) The image is grayed to generate a single-channel grayscale image corresponding to the RGB three-channel color image, denoted as I m*n ={p 11 ,p 12 …p 1n ,p 21 …p ij …p mn}, where m and n are the number of rows and columns of pixels in the image, and p ij is the pixel value at the i-th row and j-th column position;
[0015] (1b) Each pixel of the grayscale image is represented by a quantum bit, which includes the grayscale image pixel position represented by the ground state of the quantum state and the image pixel value represented by the probability amplitude of the quantum state, and the quantum image data |ψ> after quantum coding is obtained:
[0016] |ψ>=|ψ 11 >+|ψ12 >+…+|ψ 1n >+|ψ 21 >+|ψ ij >+…+|ψ mn >
[0017] Among them, |ψ ij >=α ij |0>+β ij |1> represents the pixel position of the i-th row and j-th column of the quantum image, α ij and β ij They represent the probability amplitude of the quantum bit in different ground states |0> and |1> respectively, and the two together represent the pixel value at that position;
[0018] (2) Design the basic framework of quantum neural network:
[0019] (2a) Assume that the initial state of the auxiliary quantum bit is 1, and concatenate it with the k-bit quantum image data |ψ> encoded above to obtain the k+1-bit quantum input state |ψ,1>, where the size of k is determined by the resolution of the original image;
[0020] (2b) Designing the number of quantum logic gates, that is, designing m quantum logic gates for each k-bit data qubit in the k+1-bit quantum input state, and sequentially acting on the k-bit data qubit and the auxiliary qubit to obtain m*k quantum logic gates to be designed;
[0021] (2c) Design the types of quantum logic gates. Let the number of quantum logic gate types to be selected be t, and get t m*k The structure of a quantum neural network;
[0022] (3) Search for the optimal structure under the basic framework of the above quantum neural network:
[0023] (3a) Search space for designing quantum neural network architecture:
[0024] The quantum input state is designed to have a total of k qubits. Two quantum logic gate transformation operations are performed on each qubit. The quantum logic gate types used in the design are XX gate, YY gate, ZZ gate, and quantum logic gate I gate for identity transformation. The size of the quantum neural network composed of all structures is 4 2k The search space of
[0025] (3b) The quantum evolutionary algorithm QEA is used as the search strategy to search the search space and obtain the optimal structural parameter p″ best :
[0026]
[0027] p″best is a binary-coded chromosome, where is the binary string chromosome gene corresponding to the type of the j-th quantum logic gate, n is the number of quantum logic gates;
[0028] (4) Based on the optimal structural parameter p″ best Constructing the optimal quantum neural network QNN:
[0029] (4a) For p″ best Decoding is performed to obtain the combination of n quantum logic gates corresponding to n genes of the binary string chromosome, where the determination rule of the jth quantum logic gate is as follows:
[0030]
[0031] The n quantum logic gates obtained by decoding together constitute an optimal quantum neural network structure;
[0032] (4b) Construct n quantum logic gates on the lines where the corresponding input data qubits and auxiliary qubits are located, that is, construct two quantum logic gates on the line of each qubit of the quantum input state to obtain the optimal quantum neural network.
[0033] Compared with the prior art, the present invention has the following advantages:
[0034] 1. The present invention automatically searches and designs the structure of a quantum neural network through a quantum evolution algorithm. The quantum neural network obtained by the search has better performance and higher image classification accuracy than the existing artificially designed quantum neural network.
[0035] 2. The present invention introduces quantum evolution strategy into the quantum neural network architecture search method, improves the problems of insufficient population diversity and expression ability of traditional evolutionary algorithms, and improves search performance.
[0036] 3. The present invention introduces quantum logic gate I representing identity mapping into the search space by designing the types of quantum logic gates, thereby reducing the number of unnecessary quantum logic gates and quantum bits and reducing the circuit complexity of the quantum neural network.
[0037] 4. Since the present invention adopts the quantum evolution algorithm as the search strategy and adopts the observation and quantum rotation operations of the quantum system according to the quantum evolution algorithm, it is theoretically possible to deploy the quantum evolution algorithm in increasingly complex quantum computing devices, so that the quantum evolution algorithm and the quantum neural network based on quantum circuits can run simultaneously in the quantum computing environment, making full use of the parallel advantages of quantum computing and making the quantum evolution algorithm have lower time complexity. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1It is a flow chart for realizing the present invention;
[0039] Figure 2 A quantum neural network circuit reference diagram used to design the basic framework of the quantum neural network for the present invention;
[0040] Figure 3 A Bloch sphere diagram of a quantum state used in designing a quantum logic gate in the present invention;
[0041] Figure 4 Designing quantum logic gates and quantum chromosome mapping diagrams in the search space for the present invention;
[0042] Figure 5 The optimal quantum neural network structure diagram for the MNIST image classification task searched by the present invention;
[0043] Figure 6 To remove Figure 5 The quantum neural network structure after the I gate representing the identity mapping;
[0044] Figure 7 This is a comparison chart of the accuracy of MNIST image classification performed by the present invention and the existing evolution-based neural network architecture search method. DETAILED DESCRIPTION
[0045] The embodiments and effects of the present invention are further described in detail below with reference to the accompanying drawings.
[0046] Reference Figure 1 , the implementation steps of this embodiment are as follows:
[0047] Step 1: quantize and encode the image data.
[0048] Quantum computers cannot process traditional images directly, so they need to be quantized and encoded. This example uses the Qubit-Lattice encoding method to quantize and encode image data. The specific operations are as follows:
[0049] (1.1) Grayscale the image to generate a single-channel grayscale image corresponding to the RGB three-channel color image, represented by I m*n ={p 11 ,p 12 …p 1n ,p 21 …p ij …p mn}, where p ij is the pixel value at the i-th row and j-th column position, i∈[1,m],j∈[1,n], m and n are the number of rows and columns of pixels in the image;
[0050] (1.2) Each pixel of the grayscale image is represented by a quantum bit, which includes the grayscale image pixel position represented by the ground state of the quantum state and the image pixel value represented by the probability amplitude of the quantum state, and the quantum image data |ψ> after quantum coding is obtained:
[0051] |ψ>=|ψ 11 >+|ψ 12 >+…+|ψ 1n >+|ψ 21 >+|ψ ij >+…+|ψ mn >
[0052] Among them, |ψ ij >=α ij |0>+β ij |1> represents the pixel position of the i-th row and j-th column of the quantum image, α ij and β ij They represent the probability amplitude of the quantum bit in different ground states |0> and |1> respectively, and the two together represent the pixel value at that position.
[0053] Step 2: Design the basic framework of quantum neural network.
[0054] The basic framework of the quantum neural network designed in this example is based on the quantum neural network model proposed by Google in 2018. Figure 2 As shown in the figure, the quantum circuit of the quantum neural network consists of an auxiliary quantum bit and 16 data quantum bits, which are only composed of XX and ZZ quantum logic gates. Each data quantum bit in the network passes through two quantum logic gates, and acts on the auxiliary quantum bit at the same time. This model gives the preliminary design idea of the quantum circuit in the quantum neural network, but does not give strict guidance on the selection and arrangement of the number and types of quantum logic gates. The quantum circuit structure needs to be manually designed in different tasks. This example designs the basic framework of the quantum neural network for image classification tasks. The specific operations are as follows:
[0055] (2.1) Assume that the initial state of the auxiliary quantum bit is 1, and concatenate it with the above-mentioned encoded k-bit quantum image data |ψ> to obtain the k+1-bit quantum input state |ψ,1>, where the size of k is determined by the resolution of the original image;
[0056] (2.2) Design the number of quantum logic gates, that is, design m quantum logic gates for each k-bit data qubit in the k+1-bit quantum input state, and sequentially apply them to the k-bit data qubit and the auxiliary qubit to obtain m*k quantum logic gates to be designed;
[0057] (2.3) Design the types of quantum logic gates. Let the number of quantum logic gate types to be selected be t, and get tm*k The structure of a quantum neural network.
[0058] Step 3: Design the search space of quantum neural network structure.
[0059] Reference Figure 3 In a quantum system, a quantum bit can be mapped onto a Bloch sphere, and the rotation operation of the quantum bit can be realized according to the different states mapped onto the Bloch sphere. The angle θ between a point on the Bloch sphere and the x-axis or y-axis and the angle θ between a point on the Bloch sphere and the z-axis Together they determine the state of the quantum bit. The operation of changing the state of the quantum bit is actually a quantum rotation transformation operation on the Bloch sphere. This quantum rotation transformation is divided into three types of rotation operations: rotation based on the X axis, Y axis, and Z axis. This example analyzes the quantum logic gates required to build a quantum neural network, and based on the above principles, designs the search space for the quantum neural network architecture search. The specific implementation is as follows:
[0060] (3.1) The quantum input state is designed to have a total of k qubits. Two quantum logic gate transformation operations are performed on each qubit. The formula is as follows:
[0061]
[0062] Where |ψ′> is the quantum bit state obtained after the quantum bit performs two quantum logic gate transformation operations, |ψ〉 is a single quantum bit, and U 1 (θ 1 ) and U 2 (θ 2 ) represent two quantum logic gate transformation operations, θ 1 and θ 2 are the rotation angle parameters of the corresponding quantum logic gates, which determine the transformation direction of the quantum logic gate and the degree of transformation in that direction;
[0063] (3.2) The quantum logic gate types used in the design are XX gate, YY gate, ZZ gate and quantum logic gate I gate for identity transformation. That is, according to the quantum rotation transformation, there are three types of rotation operations based on the X axis, based on the Y axis and based on the Z axis. The corresponding quantum logic gate is X θ , Y θ , Z θ Performing tensor product operations with itself respectively, we get the two-bit quantum logic gates acting on two qubits simultaneously as XX, YY, and ZZ:
[0064]
[0065]
[0066]
[0067] in ω=e iπθ , is the tensor product operation, θ is the rotation angle controlling the quantum logic gates XX, YY and ZZ;
[0068] (3.3) Inspired by the skip connection proposed in ResNet, the quantum logic gate I for identity transformation is expressed as:
[0069]
[0070] The I gate has no parameters and represents an identity mapping transformation, which will help reduce the number of unnecessary quantum logic gates and even reduce the number of required quantum bits;
[0071] (3.4) Add the above quantum logic gates that change the quantum state on the Bloch sphere to the quantum neural network architecture search space, and obtain a 4-dimensional quantum neural network consisting of all structures of the quantum neural network. 2k The search space.
[0072] Step 4: Design a search strategy to search the search space.
[0073] The existing neural network architecture search strategies can be roughly divided into three types: reinforcement learning-based, evolution-based, and gradient-based. This example introduces quantum computing theory into the evolutionary algorithm to improve population diversity and search capabilities. The quantum evolutionary algorithm QEA is used as the search strategy to search the search space to obtain the optimal structural parameters. The implementation is as follows:
[0074] (4.1) According to the type of quantum logic gate, the quantum logic gate in the search space is encoded by two quantum bits:
[0075] Reference Figure 4 , quantum logic gates XX, YY, ZZ, and I are encoded by two quantum bits, and the quantum chromosome consists of 2*m*k quantum bits encoding quantum logic gates. The encoding rules are as follows:
[0076]
[0077] (4.2) Determine the hyperparameters of the quantum evolutionary algorithm QEA: set the population size to N, the elite retention strategy ratio to ER, the full interference crossover probability to PC, and the maximum number of iterations to T;
[0078] (4.3) Initialize the quantum population Q t = {q 1 ,q 2 ,…,q i ,…,qN}, where q i is the i-th quantum chromosome individual, is the quantum gene corresponding to the type of the jth quantum logic gate on the i-th quantum chromosome, ψ 1 and ψ 2 represents two quantum bits, ψ 1 =α 1 |0>+β 1 |1>,ψ 2 =α 2 |0>+β 2 |1>, α 1 ,α 2 Respectively represent 1 , ψ 2 The probability amplitude on the ground state |0>, β 1 ,β 2 Respectively represent 1 , ψ 2 The probability amplitude on the ground state |1>, n is the total number of quantum logic gates encoded by the quantum chromosome, and the current iteration number is t = 0;
[0079] (4.4) for q i Observe and get the binary string chromosome p of a certain state i :
[0080]
[0081] in is the binary gene corresponding to the type of the jth quantum logic gate on the i-th binary string chromosome,
[0082]
[0083] (4.5) for Q t All quantum chromosomes q 1 ,q 2 ,…,q i ,…,q N Execute the observation operation of (4.4) to obtain the binary string chromosome population P of a certain state t ={p 1 ,p 2 ,…,p i ,…,p N};
[0084] (4.6) for P t Conduct individual fitness assessment:
[0085] (4.6.1) For Pt All binary chromosomes p 1 ,p 2 ,…,p i ,…,p N Decode and get the corresponding quantum neural network structure A={A 1 ,A 2 ,…,A i ,…,A N}, where the i-th chromosome p i The decoded i-th quantum neural network structure A i
[0086] It is expressed as follows:
[0087]
[0088] A i It consists of n quantum logic gates.
[0089] (4.6.2) i The n quantum logic gates are constructed on the lines where the corresponding input data qubits and auxiliary qubits are located, that is, two quantum logic gates are constructed on the line of each qubit of the quantum input state, and the quantum neural network NW is obtained. i ;
[0090] (4.6.3) For all quantum neural network structures A in A 1 ,A 2 ,…,A i ,…,A N Execute (4.6.2) to obtain the quantum neural network NW = {NW 1 ,NW 2 ,…,NW i ,…,NW N}, where NW i is based on the i-th quantum neural network structure A i The quantum neural network constructed;
[0091] (4.6.4) The image data is quantized and encoded to obtain quantum image data |ψ>;
[0092] (4.6.5) All quantum logic gate rotation parameters θ in the N quantum neural networks NW are randomly initialized, and the N quantum neural networks are respectively trained for L = 10 times using the quantum image data |ψ> based on the stochastic gradient descent optimizer to obtain the trained quantum neural network NW;
[0093] (4.6.6) Concatenate the quantum image data |ψ〉 and the auxiliary quantum bit |1〉 to obtain the quantum input state |ψ,1〉, input it into the trained quantum neural network NW, and use the Pauli-Z gate to read out the expectation of the auxiliary quantum bit to obtain the classification result of the quantum neural network;
[0094] (4.6.7) Compare the image classification results of the quantum neural network with the known image classification labels to obtain the classification accuracy: ACC = {ACC 1 ,ACC 2 ,…,ACC i ,…,ACC N}, where ACC i Represents the i-th quantum neural network NW i The accuracy rate;
[0095] (4.6.8) The model accuracy ACC is used as the individual fitness F = {F 1 ,F 2 ,F i ,…,F N}, that is, F = ACC,
[0096] Among them, F i Indicates P t The i-th chromosome p i The fitness value of t The individual with the highest fitness is denoted as p best , whose fitness value is expressed as F best ;
[0097] (4.7) Update the quantum population:
[0098] (4.7.1) Define quantum rotating gate:
[0099]
[0100] Among them, the angle of rotation θ i By quantum chromosome q i , and q i The corresponding binary string chromosome p i , the chromosome p with the highest fitness best , chromosome p i The fitness value F i And the maximum fitness value F best The direction and size are jointly determined, and the determination rules are shown in Table 1;
[0101] Table 1 Quantum revolving door angle change table
[0102]
[0103] Table 1 is a binary string chromosome p i The j-th gene position of is the chromosome p with the highest fitness best The j-th gene position of represents quantum chromosome q i The probability amplitude of the jth quantum bit in the ground state |0>, represents quantum chromosome q i The probability amplitude of the jth quantum bit in the ground state |1>, Indicates the direction of the rotation angle;
[0104] (4.7.2) Use the quantum rotating gate transformation as the mutation operator and apply it to Q t = {q 1 ,q 2 ,…,q i ,…,q N}, we get the intermediate state quantum population: Q′ t = {q 1 ′,q 2 ′,…,q i ′,…,q N '};
[0105] (4.7.3) Based on the total interference crossover probability PC for Q′ t Each quantum chromosome in Q′ undergoes full interference crossover, t All quantum chromosomes in are unfolded and their gene positions are rearranged diagonally, as shown in Table 2:
[0106] In Table 2, the current population size is 5, the quantum chromosome length is 8, and each capital letter represents a new chromosome after crossover, such as E(1)-E(2)-E(3)-E(4)-E(5)-E(6)-E(7)-E(8). This quantum full interference crossover method can make full use of the chromosome information in the population as much as possible, improve the locality and one-sidedness of the ordinary crossover operator, and can effectively jump out of the local optimum and avoid premature phenomenon. The final state quantum population is obtained: Q″ t ={q″ 1 ,q″ 2 ,…,q″ i ,…,q″ N}:
[0107] where q″ i is the i-th quantum chromosome individual, is the quantum gene corresponding to the type of the jth quantum logic gate on the i-th quantum chromosome, ψ1 ″ and ψ 2 ″ represents two quantum bits, ψ 1 ″=α 1 ″|0>+β 1 ″|1>,ψ 2 ″=α 2 ″|0>+β 2 ″|1>,α 1 ″,α 2 ″ respectively represent the 1 ″,ψ 2 The probability amplitude on the ground state |0> of ″, β 1 ″,β 2 ″ respectively represent in ψ″ 1 ,ψ 2 ″ is the probability amplitude on the ground state |1〉, n is the total number of quantum logic gates encoded by the quantum chromosome;
[0108] Table 2 Full Interference Crossover
[0109]
[0110] (4.7.4) Based on the observation rule of step (4.4), observe the final state quantum population Q″ t , we get a binary string chromosome population P″ in a certain state t ={p″ 1 ,p″ 2 ,…,p″i,…,p″ N},in Represents the population P″ t The i-th binary string chromosome in , is the final state quantum population Q″ t The binary gene corresponding to the type of the jth quantum logic gate on the i-th binary string chromosome,
[0111] (4.7.5) For P t Based on step (4.6), the individual fitness is evaluated to obtain the corresponding fitness set:
[0112] F″={F″ 1 ,F″ 2 ,…,F″ i ,…,F″ N},
[0113] Among them, F i Indicates P t ″The i-th chromosome P in ″ i The fitness value of best =P t The individual with the highest fitness among them;
[0114] (4.7.6) Determine whether t = T:
[0115] If so, then p″ best Output as optimal structural parameters:
[0116]
[0117] Among them, p″ best is a binary string chromosome population P″ in a certain state t The individual with the highest fitness, is p″ best The binary gene corresponding to the type of the j-th quantum logic gate in is, n is the number of quantum logic gates, and the search ends;
[0118] Otherwise, according to P t The fitness ranking result F of ″ is used to execute the elite retention strategy, that is, select P t The N*ER elite chromosome individuals with the highest fitness in ″ are taken as P t , select Q t The corresponding N*ER quantum chromosomes in ″ are Q t , select the corresponding N*ER fitness in F″ as F, let t=t+1, and return to step (4.4).
[0119] Step 5: Based on the optimal structural parameter p″ best Construct an optimal quantum neural network QNN.
[0120] (5.1) For p″ best Decoding is performed to obtain the combination of n quantum logic gates corresponding to the n gene positions of the binary string chromosome, where the determination rule of the i-th quantum logic gate is as follows:
[0121]
[0122] (5.2) n quantum logic gates are constructed on the lines where the corresponding input data qubits and auxiliary qubits are located, that is, two quantum logic gates are constructed on the line of each qubit of the quantum input state to obtain the optimal quantum neural network. The specific implementation is as follows:
[0123] (5.2.1) Create a quantum virtual environment in the Cirq framework, build quantum circuits for representing quantum images based on quantum-encoded quantum image data, and assign two quantum logic gates to each quantum circuit to form a quantum neural network;
[0124] (5.2.2) The quantum circuit of the quantum neural network is tensorized in the TFQ framework, and the quantum neural network is trained using the SGD optimizer to obtain the optimal quantum neural network after training.
[0125] The effect of the present invention is described below through experimental simulation:
[0126] 1. Experimental simulation environment:
[0127] The quantum circuit of the quantum neural network is built by the Cirq framework. The training and evaluation of the quantum neural network are run on the quantum simulator TensorFlow-quantum and Cirq, which simulates the operating environment of quantum computing devices, such as noisy intermediate-scale quantum NISQ devices. The quantum evolutionary algorithm is written in Python and uses scientific computing frameworks such as Numpy. The hardware environment required for the experiment is shown in Table 3.
[0128] Table 3 Hardware environment
[0129] name model processor Intel Core i7-7800X@3.50GHz Memory 64GB Graphics Nvidia GeForce GTX2080 harddisk 2.2TB
[0130] 2. Experimental setup:
[0131] In order to express classical digital images in quantum systems, the qubit-lattice encoding method is adopted. After normalizing the traditional image, 16-bit quantum bits are used to represent the image data, and one auxiliary quantum bit represents the output data. The state of the output quantum bit is observed to obtain the current image classification result.
[0132] The circuit construction of quantum neural network adopts Cirq framework, and the training and optimization adopts TFQ framework. Specifically, firstly, a quantum virtual environment is created in Cirq framework, quantum circuits for representing quantum images and quantum neural networks are built, and quantum circuits are tensorized in TFQ framework, and then trained using SGD optimizer. For the quantum evolution algorithm in quantum neural network architecture search, the number of quantum populations is set to 10, the number of evolutionary rounds is set to 50, the update of quantum revolving gate parameters is shown in Table 1, and the trigger probability of full interference crossover is 0.3.
[0133] 3. Experimental content:
[0134] Simulation experiment 1, under the above simulation environment and experimental equipment conditions, using the "3" and "6" categories in the MNIST data set as the final data set, for the classification task of the data set, the quantum neural network is searched by the present invention as follows Figure 5 As shown, since the I gate represents an identity mapping, Figure 5 Quantum neural networks need to be streamlined to remove Figure 5 In the I gate, we get Figure 6 The final quantum neural network shown.
[0135] Use Figure 6 The quantum neural network shown is similar to Figure 2 The artificially designed quantum neural network proposed by Farhi et al. is used for image classification, and its classification accuracy and complexity are compared. The results are shown in Table 4;
[0136] Table 4 Comparison of model classification accuracy and complexity
[0137] Network Model Number of qubits Number of quantum logic gates Parameter quantity Classification Accuracy Existing artificially designed QNNs 17 32 32 88.51% The QNN obtained by the present invention 16 25 25 93.82%
[0138] By comparison Figure 5 and Figure 2 It can be seen that compared with the artificially designed quantum neural network, the quantum logic gates of the searched quantum neural network are more disordered, and Figure 5 There is only an identity transformation I gate on the circuit of the quantum bit (1, 0), so this quantum bit does not participate in the training of the quantum neural network, and the total number of quantum bits is reduced from 17 to 16. By comparison Figure 6 and Figure 2 Combined with Table 4, it can be seen that the automatic search of quantum neural networks by the method proposed in the present invention not only improves the classification accuracy compared with the manually designed quantum neural networks, but also reduces the number of quantum logic gates and parameters from 32 to 25, with a reduction ratio of 21.88%. Therefore, the quantum neural network searched by the present invention has lower complexity, which reduces the actual difficulty of model deployment and quantum system preparation.
[0139] Simulation experiment 2, under the above simulation environment and experimental equipment conditions, using the "3" and "6" categories in the MNIST data set as the final data set, the quantum neural network searched by QEA in the present invention and the quantum neural network searched by EA based on the existing evolutionary neural network architecture search method were used for image classification. The search process of the best classification accuracy is shown in the following figure. Figure 7 As shown, the best classification accuracies of QEA and EA are 93.82% and 91.69%, respectively.
[0140] The above two search strategies were run independently 30 times for observation, and their average classification accuracy and standard deviation were compared. The results are shown in Table 5.
[0141] Table 5 Comparison of search strategies
[0142] Search strategy Average classification accuracy Standard Deviation QEA 93.29% 0.40 EA 90.67% 0.68
[0143] Compare Table 5 and combine Figure 7It can be seen that the quantum chromosome used in the present invention has an advantage in representation ability, so QEA is easier to find a better quantum neural network in a huge discrete search space than EA, and its image classification accuracy is higher. More importantly, in theory, QEA can be modified and deployed in quantum circuits, so that QEA and QNN can run simultaneously in quantum computers, making full use of the parallel advantages of quantum computing, so that the quantum evolutionary algorithm has a lower time complexity. It shows that the present invention uses QEA as a search strategy for quantum neural network architecture search, which is more feasible and more effective than the prior art EA.
Claims
1. A quantum simulator-based evolutionary quantum neural network architecture search method, characterized in that: These include: (1) Use Qubit-Lattice encoding to quantize image data: (1a) The image is grayed to generate a single-channel grayscale image corresponding to the RGB three-channel color image, denoted as I m*n ={p 11 , p 12 ...p 1n , p 21 ...p ij ...p mn }, where m and n are the number of rows and columns of pixels in the image, and p ij is the pixel value at the i-th row and j-th column position; (1b) Each pixel of the grayscale image is represented by a quantum bit, which includes the grayscale image pixel position represented by the ground state of the quantum state and the image pixel value represented by the probability amplitude of the quantum state, and the quantum image data |ψ> after quantum coding is obtained: |ψ>=|ψ 11 >+|ψ 12 >+…+|ψ 1n >+|ψ 21 >+|ψ ij >+…+|ψ mn > Among them, |ψ ij >=α ij |0>+β ij |1> represents the pixel position of the i-th row and j-th column of the quantum image, α ij and β ij They represent the probability amplitude of the quantum bit in different ground states |0> and |1> respectively, and the two together represent the pixel value at that position; (2) Design the basic framework of quantum neural network: (2a) Assume that the initial state of the auxiliary quantum bit is 1, and concatenate it with the above-mentioned encoded k-bit quantum image data |ψ> to obtain the k+1-bit quantum input state |ψ,1>, where the size of k is determined by the resolution of the original image; (2b) Designing the number of quantum logic gates, that is, designing m quantum logic gates for each k-bit data qubit in the k+1-bit quantum input state, and sequentially acting on the k-bit data qubit and the auxiliary qubit to obtain m*k quantum logic gates to be designed; (2c) Design the types of quantum logic gates. Let the number of quantum logic gate types to be selected be t, and get t m*k The structure of a quantum neural network; (3) Search for the optimal structure under the basic framework of the above quantum neural network: (3a) Search space for designing quantum neural network architecture: The quantum input state is designed to have a total of k qubits. Two quantum logic gate transformation operations are performed on each qubit. The quantum logic gate types used in the design are XX gate, YY gate, ZZ gate, and quantum logic gate I gate for identity transformation. The size of the quantum neural network composed of all structures is 4 2k The search space of (3b) The quantum evolutionary algorithm QEA is used as the search strategy to search the search space and obtain the optimal structural parameter p″ best : p″ best is a binary-coded chromosome, where is the binary string chromosome gene corresponding to the type of the j-th quantum logic gate, n is the number of quantum logic gates; (4) Based on the optimal structural parameter p″ best Constructing the optimal quantum neural network QNN: (4a) For p″ best Decoding is performed to obtain the combination of n quantum logic gates corresponding to n genes of the binary string chromosome, where the determination rule of the jth quantum logic gate is as follows: The n quantum logic gates obtained by decoding together constitute an optimal quantum neural network structure; (4b) Construct n quantum logic gates on the lines where the corresponding input data qubits and auxiliary qubits are located, that is, construct two quantum logic gates on the line of each qubit of the quantum input state to obtain the optimal quantum neural network.
2. The method according to claim 1, characterized in that In (3a), two quantum logic gate transformation operations are performed on each quantum bit, and the formula is as follows: Where |ψ′> is the quantum bit state obtained after the quantum bit performs two quantum logic gate transformation operations, |ψ> is a single quantum bit, U1(θ1) and U2(θ2) represent two quantum logic gate transformation operations respectively, θ1 and θ2 are the rotation angle parameters of the corresponding quantum logic gates, which determine the transformation direction of the quantum logic gate and the degree of transformation in this direction.
3. The method according to claim 1, characterized in that In (3a), quantum logic gate types XX gate, YY gate, ZZ gate and quantum logic gate I gate for identity transformation are designed and implemented as follows: (3a1) According to the quantum rotation transformation, there are three types of rotation operations: based on the X axis, based on the Y axis, and based on the Z axis. The corresponding quantum logic gate is X θ , Y θ , Z θ Performing tensor product operations with themselves respectively, we get the two-bit quantum logic gates acting on two qubits simultaneously as XX, YY, and ZZ: in ω=e iπθ , is the tensor product operation, θ is the rotation angle controlling the quantum logic gates XX, YY and ZZ; (3a2) The quantum logic gate I used for identity transformation is expressed as: The I gate has no parameters and represents an identity mapping transformation.
4. The method according to claim 1, characterized in that: In (3b), the quantum evolutionary algorithm QEA is used to search the search space, which is implemented as follows: (3b1) Depending on the type of quantum logic gate, two quantum bits are used to encode the quantum logic gate in the search space according to the following rules: (3b2) Determine the hyperparameters of the quantum evolutionary algorithm QEA: set the population size to N, the elite retention strategy ratio to ER, the full interference crossover probability to PC, and the maximum number of iterations to T; (3b3) Initialize the quantum population Q t ={q1, q2, ..., q i , ..., q N }, where q i is the i-th quantum chromosome individual, is the quantum gene bit corresponding to the type of the jth quantum logic gate on the i-th quantum chromosome, ψ1 and ψ2 represent two quantum bits, ψ1 = α1|0> + β1|1>, ψ2 = α2|0> + β2|1>, α1, α2 represent the probability amplitudes on the ground state |0> of ψ1, ψ2, β1, β2 represent the probability amplitudes on the ground state |1> of ψ1, ψ2, n is the total number of quantum logic gates encoded by the quantum chromosome, and the current iteration number is t = 0; (3b4) for q i Observe and get the binary string chromosome p of a certain state i : in is the binary gene bit corresponding to the type of the jth quantum logic gate on the i-th binary string chromosome, (3b5) vs. Q t All quantum chromosomes q1, q2, ..., q i , ..., q N Execute the observation operation (3b4) to obtain the binary string chromosome population P of a certain state t ={p1, p2, ..., p i , ..., p N }; (3b6) for P t Perform individual fitness evaluation to obtain the fitness set corresponding to the current population: F={F1,F2,...,F i ,...,F N }, Among them, F i Indicates P t The i-th chromosome p i The fitness value of t The individual with the highest fitness is denoted as p best , whose fitness value is expressed as F best ; (3b7) Define quantum rotating gate: Among them, the angle θ of the rotation transformation is given by the quantum chromosome q i , and q i The corresponding binary string chromosome p i , the chromosome p with the highest fitness best , chromosome p i The fitness value F i And the maximum fitness value F best jointly determine its direction and size; (3b8) Use the quantum rotating gate transformation as the mutation operator and apply it to Q t ={q1, q2, ..., q i , ..., q N }, we get the intermediate state quantum population: Q′ t ={q1′, q2′, ..., q i ′, ..., q N '}; (3b9) According to the total interference crossover probability PC, Q′ t Each quantum chromosome in Q′ undergoes full interference crossover, t All quantum chromosomes in the , and their gene positions are rearranged diagonally to obtain the final state quantum population Q″ t ={q″1, q″2,...,q″ i , ..., q″ N }; (3b10) Based on the observation rule of (3b4), observe the final state quantum population Q″ t , we get a binary string chromosome population P″ in a certain state t ={p″1, p″2,...,p″ i , ..., p″ N }; (3b11) for P t ″Evaluate individual fitness and obtain the corresponding fitness set: F″={F″1,F″2,...,F″ i ,...,F″ N }, Among them, F i Indicates P t "The i-th chromosome p in" i The fitness value of best =P t The individual with the highest fitness among them; (3b12) Determine whether t=T holds: If so, then p″ best Output as the optimal structural parameters and end the search; Otherwise, according to P t ”Fitness ranking result F”, select P t The N*ER elite chromosome individuals with the highest fitness in ″ are taken as P t , select Q t The corresponding N*ER quantum chromosomes in ″ are Q t , select the corresponding N*ER fitness in F″ as F, set t=t+1, and return to (3b4).
5. The method according to claim 1, characterized in that: In (4b), n quantum logic gates are constructed on the lines where the corresponding input data qubits and auxiliary qubits are located to obtain the optimal quantum neural network, which is implemented as follows: (4b1) Create a quantum virtual environment in the Cirq framework, build a quantum circuit for representing the quantum image based on the quantum image data after quantum encoding, and allocate two quantum logic gates on each quantum circuit to form a quantum neural network; (4b2) The quantum circuit of the quantum neural network is tensorized in the TFQ framework, and the quantum neural network is trained using the SGD optimizer to obtain the optimal quantum neural network.
6. The method according to claim 4, characterized in that: The (3b6) for the current population P t Perform individual fitness evaluation to obtain the fitness set F corresponding to the current population, which is implemented as follows: (3b6a) for P t All binary chromosomes p1, p2, ..., p i , ..., p N Decode according to the following rules to obtain the corresponding quantum neural network structure A = {A1, A2, ..., A i , ..., A N }, where the i-th chromosome p i The decoded i-th quantum neural network structure A i It is expressed as follows: (3b6b) Based on the quantum neural network structure A, the quantum logic gate circuit of the quantum neural network is constructed, and the quantum neural network NW = {NW1, NW2, ..., NW i , ..., NW N }, where NW i is based on the i-th quantum neural network structure A i The quantum neural network constructed; (3b6c) quantize and encode the image data to obtain quantum image data |ψ>; (3b6d) randomly initialize all quantum logic gate rotation parameters θ in the N quantum neural networks NW, and perform L iterative training on the N quantum neural networks respectively using the quantum image data |ψ> based on the stochastic gradient descent optimizer; (3b6e) The quantum image data |ψ> and the auxiliary quantum bit |1> are concatenated to obtain the quantum input state |ψ,1>, which is input into the trained quantum neural network NW. Finally, the expectation of the auxiliary quantum bit is read out using the Pauli-Z gate to obtain the classification result of the quantum neural network, which is then compared with the known image classification label to obtain the classification accuracy ACC = {ACC1, ACC2, ..., ACC i , ..., ACC N }, where ACC i Represents the i-th quantum neural network NW i The accuracy rate; (3b6f) The model accuracy ACC is used as the individual fitness F = {F1, F2, F i , ..., F N }, that is, F=ACC.
Citation Information
Patent Citations
Image classification method based on neural network architecture search
CN111898689A
Handwritten picture classification method based on quantum self-learning and self-training network
CN112446432A