A traffic sign recognition method based on quantum convolutional neural network
By introducing quantum channel attention layer and quantum encoding method that separates features from channels in the traffic sign recognition model, the calculation complexity and immediacy of the existing model in multi-channel color image processing is solved, and efficient traffic signs are achieved Improved recognition performance.
Patent Information
- Application Number
- CN202411245459.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-06
- Publication Date
- 2024-11-19
- Estimated Expiration
- 2044-09-06
AI Technical Summary
The existing traffic sign recognition model, especially the classic CNN-based model, is difficult to effectively capture the information between channels when processing multi-channel color image data, the calculation complexity is high, and it is difficult to implement on medium-sized quantum devices, and the data processing is Immediateness requirements are difficult to meet the needs of autonomous driving.
Using the traffic sign recognition method based on quantum convolution neural network, the quantum encoding method for separation of features and channels is designed, combined with the quantum controlled convolution layer and the quantum pooling layer to realize the multi-channel data Efficient processing and training with cross entropy loss and Adam optimizer.
It realizes efficient multi-channel data processing of traffic signs, effectively captures information between channels, improves identification performance, reduces noise errors, and meets the immediate needs of autonomous driving.
Smart Images

Figure CN118762349B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of image recognition, and in particular relates to a traffic sign recognition method based on quantum convolutional neural network. Background Art
[0002] Traffic sign recognition is of great significance in autonomous driving. It helps improve the safety and efficiency of autonomous vehicles on the road. Traffic signs convey various information through colors and patterns. Different colors often correspond to different types of road conditions, dangers or indicative behaviors, so the color information contained is particularly important. There are many models that can perform traffic sign recognition, such as some models based on generative adversarial networks (GAN) or convolutional neural networks (CNN), which can perform the task well. However, these models still have obvious limitations and are not well adapted to the existing autonomous driving application environment. These models require a large amount of data for training and a large amount of calculation. In situations where the amount of data is large and it is difficult to ensure sufficient computing performance, such as in actual autonomous driving situations, processing takes a certain amount of time. For autonomous driving, the immediacy of data processing is very important.
[0003] The quantum bits (qubits) used in quantum computing have superposition properties and can be in a superposition of multiple states at the same time, which means that quantum computers can handle multiple computing paths, thus having exponential computing power on certain problems. Therefore, quantum computing is expected to solve problems that are difficult to solve with classical computing. Applying it to autonomous driving can still maintain computing speed in the case of large amounts of data, and is expected to ensure the required immediacy. Imitating CNN, one of the most commonly used deep learning algorithms in the field of image recognition, a quantum convolutional neural network (QCNN) was proposed. Compared with classical CNN, QCNN has some potential advantages. For example, when processing large-scale image data, QCNN is expected to be faster than classical CNN. Compared with most quantum machine learning architectures, QCNN has a shallower circuit depth, which can reduce errors caused by noise, and is quite likely to operate on current noisy intermediate-scale quantum (NISQ) devices.
[0004] However, few studies on QCNN involve the processing of multi-channel data. Most studies on image recognition are limited to simple grayscale data and lack the ability to process color image data. The application part of a few studies uses multi-channel data, but this part of the research often cannot effectively capture the information between channels, or requires a large number of additional quantum bits, resulting in large quantum resource overhead and high computational complexity, which is difficult to implement on NISQ devices. In general, current QCNN-related research lacks the ability to effectively process multi-channel complex data. Summary of the invention
[0005] Purpose of the invention: In order to solve the problems existing in the above-mentioned prior art, the present invention provides a traffic sign recognition method based on quantum convolutional neural network.
[0006] Technical solution: The present invention provides a traffic sign recognition method based on quantum convolutional neural network, which specifically includes the following steps:
[0007] Step 1: Collect traffic sign images and perform label processing for each image; the collected traffic sign images and corresponding labels are used as sample data;
[0008] Step 2: Establish a quantum convolutional neural network, which includes a preprocessing layer, a quantum circuit and a classification layer;
[0009] The preprocessing layer preprocesses the sample data, and the preprocessing specifically includes performing a softmax-like processing on the sample data, performing amplitude encoding on the data after the softmax-like processing, obtaining C channel qubits and I1 feature qubits, and sending the obtained qubits to the quantum circuit for processing;
[0010] The quantum circuit includes a quantum computing layer and an independent controlled convolution layer, the quantum computing layer includes a controlled convolution layer, a quantum pooling layer and a quantum channel attention layer, the controlled convolution layer performs a convolution operation on the input feature quantum bits, selects w feature quantum bits after the convolution operation and inputs them into the quantum pooling layer, w≤I1, and the quantum pooling layer transfers the information contained in the control quantum bit to the controlled quantum bit; then the quantum channel attention layer is used to extract the channel attention information of the control quantum bit and the channel quantum bit, and the control quantum bit is discarded; it is judged whether the preset stop condition is met, if not, the output of the current quantum computing layer is input into the next quantum computing layer until the preset stop condition is met, if yes, the output of the current quantum computing layer is input into an independent controlled convolution layer, and the output of the independent controlled convolution layer is used as the output of the quantum circuit; and the output of the quantum circuit is input into the classification layer;
[0011] The classification layer outputs the classification result of the traffic sign;
[0012] Step 3: Train the quantum convolutional neural network and use the trained quantum convolutional neural network for traffic sign recognition.
[0013] Furthermore, the softmax class in step 2 uses the following formula to process the sample data:
[0014] ;
[0015] Among them, M represents the temperature of class softmax, x represents an N-dimensional sample data vector,x i Representation vector x The i-th pixel of ; i=1,2,…,N; j1=1,2,…,N; p is a multi-channel data vector with N pixels and C channels processed by the softmax class, p i represents the i-th pixel of vector p;
[0016] The expression of the amplitude coding is as follows:
[0017] ;
[0018] in, p i+NC represents the first pixel of the i-th pixel of vector p c The value of each channel; U(.) represents the amplitude encoding function, represents the ground state of the channel qubit, Represents the ground state of the characteristic quantum bit.
[0019] Furthermore, the stopping condition preset in step 2 is that the number of characteristic quantum bits output by the current quantum computing layer meets a preset number.
[0020] Furthermore, the controlled convolutional layer consists of two sequentially connected C quantum convolution layer, using the ground state control of the channel qubit 2 C Whether a quantum convolution layer is used or not, one ground state controls one quantum convolution layer; each quantum convolution layer has the same structure, including I1 / 2 2-qubit first unitary elements and (I1-2) / 2 2-qubit second unitary elements, the I1 characteristic qubits are combined in pairs in turn to obtain I1 / 2 characteristic qubit groups, which are input into the corresponding first unitary element, and the outputs of all first unitary elements corresponding to the first characteristic qubit and the outputs corresponding to the I1th characteristic qubit are directly used as the first output and I1th output of the quantum convolution layer, and the remaining outputs of all first unitary elements are combined again in pairs to obtain (I1-2) / 2 output groups, which are input into the corresponding second unitary element.
[0021] Furthermore, the first and second unitary elements have the same structure but different parameters; the structure of the unitary element As shown below:
[0022] ;
[0023] in, represents the parameter of the unitary element, , , as well as The parameters are , , , The first to fourth parameterizations R x Door, , , as well as The parameters are , , , The first to fourth parameterizations R z Door, , The parameters are , The first and second parameters are controlled R x Door, represents tensor product;
[0024] First to fourth parameterization R x The gate structure is the same, and the corresponding matrix form As shown below:
[0025] ;
[0026] in, For parameterization R x The parameter of the gate, j is the imaginary unit;
[0027] First to fourth parameterization R z The gate structure is the same, and the corresponding matrix form As shown below:
[0028] ;
[0029] in, For parameterization R z Parameters of the door;
[0030] First to second parameterization controlled R x The gate structure is the same, and the corresponding matrix form As shown below:
[0031] ;
[0032] in, Parameterized R x Parameters of the door.
[0033] Furthermore, the quantum channel attention layer inputs the control qubit into the third unitary element, and transfers the information contained in the output of the third unitary element to the channel qubit through a 2-qubit quantum transfer block. The structure of the third unitary element is the same as that of the first and second unitary elements. The expression of the quantum transfer block is as follows:
[0034] ;
[0035] Where T represents the quantum transfer block, Indicates parameterized controlled R x Door, Indicates parameterized controlled R z Door, X For Pauli-X gate, I is the identity matrix; and X The expression is as follows:
[0036] ;
[0037] ;
[0038] in, Indicates parameterized controlled R z Parameters of the door.
[0039] Furthermore, the quantum pooling layer adopts a symmetric dual-pooling structure, including a plurality of 2-qubit quantum transfer blocks, and the quantum pooling layer uses the quantum transfer block to transfer the information contained in the control quantum bit to the controlled quantum bit adjacent to the control quantum bit.
[0040] Furthermore, the cross entropy loss is used as the loss function during training. The expression of the cross entropy loss L is as follows:
[0041] ;
[0042] in, K is the number of training set data, Represents the prediction using quantum convolutional neural network x k Label is the correct label y k The probability of x k is the kth training data, are the parameters of the quantum convolutional neural network, and F(.) represents the quantum convolutional neural network.
[0043] Furthermore, the gradient of cross entropy is calculated using the following formula:
[0044] ;
[0045] in, Indicates differential calculation;
[0046] Parameters of quantum circuits The gradient of is calculated using the following formula:
[0047] ;
[0048] in, r is the shift constant associated with the quantum gate.
[0049] Furthermore, the Adam optimizer is used to optimize the parameters:
[0050] ;
[0051] in, represents the learning rate, subscript Represents the first parameters, t represents the number of iterations, m represents the momentum that changes with the gradient, v Represents the rate of dynamic change according to the steepness of the gradient, , and are the basic parameters of the Adam optimizer, represents the first quantum convolutional neural network at the t+1th iteration The value of the parameter, represents the first quantum convolutional neural network at the tth iteration The value of the parameter, for v The correction value of is the corrected value of m.
[0052] Beneficial effects:
[0053] 1. The present invention realizes efficient multi-channel data processing, can effectively capture the inter-channel information of traffic signs, and improves the performance of traffic sign recognition.
[0054] 2. For multi-channel data, the present invention designs a quantum coding method that separates features from channels. Such coding is consistent with the data processing method of the proposed architecture.
[0055] 3. The present invention introduces a quantum channel attention layer in the quantum convolutional neural network, and implements the channel attention process of image recognition in the form of quantum circuits, providing a possible direction for pure quantum machine learning. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] Figure 1 It is a schematic diagram of the overall architecture of the present invention.
[0057] Figure 2 It is a schematic diagram of the preprocessing and encoding process of the present invention.
[0058] Figure 3 This is a schematic diagram of a unitary circuit on 2 quantum bits.
[0059] Figure 4 Figure 1 is a circuit diagram of a quantum convolution block on 6 qubits.
[0060] Figure 5 Figure 2 is a circuit diagram of a controlled convolutional layer on 6 qubits.
[0061] Figure 6 This is a circuit diagram of a quantum transfer block on 2 qubits.
[0062] Figure 7 This is a circuit diagram of the quantum pooling layer on 5 qubits.
[0063] Figure 8 This is a circuit diagram of the quantum channel attention layer on 4 qubits.
[0064] Fig. 9 This is a schematic diagram of the combination of the quantum pooling layer and the quantum channel attention layer.
[0065] Fig.10 It is a structural diagram of the complete quantum circuit of this embodiment. DETAILED DESCRIPTION
[0066] The accompanying drawings, which constitute a part of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.
[0067] The overall workflow of the quantum channel attention convolutional neural network architecture of this embodiment is as follows Figure 1 As shown. , , , Represent the quantum states of feature qubits, channel qubits, retained qubits after pooling, and discarded qubits, respectively. The traffic sign dataset used in this embodiment is TSRD, and this embodiment selects a total of 8 types of traffic signs numbered (5, 10, 28, 37, 52, 54, 55, 56) as training and test data for multi-classification tasks. Each image data in the dataset is cropped to the size of the traffic sign according to the traffic sign position coordinates in the label, and then scaled to a size of 16×16 pixels, and then a fixed preprocessing process is applied. Because the amount of training data contained in different categories varies greatly, ranging from 36 to 2100, it is easy for the model to have a tendency to have a large amount of data during training. Therefore, when generating a data set, the amount of training data for each category is scaled to the same number of 256, and a part of the category with a large amount of data is deleted, while the category with a small amount of data will copy its data several times.
[0068] In the preprocessing layer, the raw data is encoded into quantum data after preprocessing. In order to encode the classical image number x into quantum data for quantum circuit processing, this embodiment uses an amplitude encoding encoding method. The general form of the amplitude encoder is shown in the following formula:
[0069] ;
[0070] in x is a classic data vector of N dimensions, x i is a vector x The i-th element of x i As a base state The amplitude of is accumulated to become the encoded quantum data. Since the feasible quantum state needs to be a unit vector, that is, , so it is necessary to Amplitude coding can encode N-dimensional classical data into qubits, It represents rounding up, and stores a large amount of data in relatively few quantum bits. It has considerable resource advantages for processing large-scale image data, and can process classical data in parallel by processing a small number of quantum bits.
[0071] However, traffic sign image data contains a lot of data with low contrast, where the difference between bright and dark areas is small. When amplitude encoding is performed on such data, the difference between the amplitudes of different ground states is small, which is reflected in the quantum state as less entangled information, making it difficult to be processed by quantum circuits. Figure 2 As shown, this embodiment uses a softmax-like operation to preprocess the original image data:
[0072] ;
[0073] Where j1=1,2,…,N; a softmax-like operation is used to concentrate the amplitude data on channels and positions with higher brightness, increasing the effectiveness of the entangled information encoded in the amplitude. Since the brightness information of the image is limited to [0,1], the result obtained by the general softmax operation is too smooth, so it is necessary to use the Softmax method with temperature. M in the above formula is the temperature of softmax. The closer the temperature is to 0, the larger the proportion of processed data corresponding to the same original data difference, and a higher contrast image can be obtained. Since the result of the softmax operation satisfies , this embodiment believes that such a pre-processing process meets the normalization requirements of the quantum state. The M of the present invention uses 0.1, and such a temperature is sufficient to generate an image with sufficiently high contrast.
[0074] The signal image is a color image, and its data has three channels: red, green, and blue. For such multi-channel data, the grayscale data of different channels are connected together to form a mixed grayscale image containing data from different channels. Then the pre-processed data is encoded into quantum data using amplitude coding:
[0075] ;
[0076] in is a multi-channel data vector with N pixels and C channels, pre-processed by softmax. p i+NC Indicates its i The pixel c The value of each channel. U(.) represents the amplitude encoding function. represents the ground state of the channel qubit, Represents the ground state of the characteristic quantum bit. The normalization method used in the classic method is not used here because the vector p processed by softmax can satisfy , thus through The property of directly realizes normalization without further calculation. In the encoding process, the parameter i and c Affects the ground state of different quantum bits respectively. i The value will cause the previous ⌈log i The ground state of each quantum bit is different, and different c The value will cause the post-log cThis encoding method divides quantum bits into two categories, namely channel quantum bits (in this embodiment, red, green, and blue are three channels, so two channel quantum bits q are used). c0 ,q c1 The data of the red, green and blue channels in the characteristic quantum bit are respectively related to the ground state of the channel quantum bit. , and Entanglement can be achieved by locating the data of different channels stored in parallel in the characteristic quantum bits through the characteristic quantum bits. This encoding method makes it easier for the subsequent quantum channel attention layer to affect the channel characteristic information in a targeted manner.
[0077] The quantum computing layer is the quantum circuit part of QCACNN. The quantum computing layer contains three modules, namely the quantum controlled convolution layer, the quantum pooling layer and the quantum channel attention layer.
[0078] For the classic convolution process, the input data is processed by a series of convolution kernels, and the filtering operation is performed in a small area to obtain local features. The filtering operations of the same convolution kernel at different positions share parameters to save the number of parameters and extract the same features at different positions.
[0079] In the proposed quantum convolutional neural network architecture, the convolution layer is composed of a series of 2-qubit unitary elements called convolution blocks. The unitary element uses a 10-parameter convolution circuit, including the first to fourth parameterized R x Gate, first to fourth parameterization R z The gate is controlled by the first and second parameter R x Door. R x Door and R z The gate is a single-qubit gate, controlled R x The gate is a 2-qubit gate. The circuit of the unitary element is as follows Figure 3 As shown, such a unitary element achieves a balance between circuit scale and classification performance. The circuit expression of the unitary element is as follows:
[0080] ;
[0081] in, represents the parameter of the unitary element, , , as well as The parameters are , , , The first to fourth parameterizations R x Door, , , as well as The parameters are , , , The first to fourth parameterizations R z Door, , The parameters are , The first and second parameters are controlled R x Door, Represents a tensor product.
[0082] First to fourth parameterization R x The gate structure is the same, and the corresponding matrix form As shown below:
[0083] ;
[0084] in, For parameterization R x Parameters of the door.
[0085] First to fourth parameterization R z The gate structure is the same, and the corresponding matrix form As shown below:
[0086] ;
[0087] in, For parameterization R z The parameter of the gate, j is the imaginary unit.
[0088] First-second parameterization Controlled parameterization R x The gate structure is the same, and the corresponding matrix form As shown below:
[0089] ;
[0090] in, Parameterized R x Parameters of the door.
[0091] Applying such a series of unitary elements between adjacent quantum bits is similar to extracting local features in an image using classical convolution, forming a quantum convolution layer. The circuit of the quantum convolution layer is shown in Figure 1. Figure 4 As shown. Combine I1 characteristic quantum bits in pairs in sequence to obtain I1 / 2 quantum bit groups, input the quantum bit groups to the corresponding first unitary element, directly use the outputs corresponding to the first characteristic quantum bit and the outputs corresponding to the I1th characteristic quantum bit in the outputs of all first unitary elements as the first output and the I1th output of the quantum convolution block, combine the remaining outputs of all first unitary elements again in pairs to obtain (I1-2) / 2 output groups, and input the output groups to the corresponding second unitary element, where I1 is the number of characteristic quantum bits input to the controlled convolution layer; the first and second unitary elements have the same structure, all first unitary elements share a set of parameters, and all second unitary elements share a set of parameters, so that a quantum convolution layer shares two sets of parameters, and there are 20 parameters in total in this embodiment. The parameter sharing behavior of the quantum convolution layer is an imitation of the shift-invariant characteristics of the convolution process filter of the classical convolutional neural network, and also includes the purpose of saving the amount of parameters.
[0092] Although under the condition of amplitude coding, initially, the quantum bit (q 0 ,q 1 etc.) contain the low-frequency features of the image, while the low-order quantum bits (q 5 ,q 4 The quantum convolutional neural network (QCNN) contains high-frequency features of the image. The role of each quantum bit is not equal, but the unitary elements at different positions still share parameters. This is because after the unitary transformation provided by the quantum layer, the quantum information at different positions will be quickly dispersed to all quantum bits, and the inequality of quantum bits will only stay in the first few layers. The quantum convolution layer used in this embodiment is not cyclically connected, that is, there is no unitary element connecting the first quantum bit and the last quantum bit. This is because the difference in the scale of the features represented by the two quantum bits is too large, and the behavior of exchanging information with each other is not reasonable.
[0093] The architecture proposed in this paper divides quantum bits into two categories, namely channel quantum bits and feature quantum bits. In the actual convolution operation, the quantum convolution layer is only applied to the feature quantum bits to extract the features of the image data. The channel quantum bits are used to control whether the quantum convolution layer is used or not. Since this embodiment uses two channel quantum bits, it has four ground states ( , , and ), so 4 quantum convolution layers can be controlled. The proposed architecture uses such quantum controlled convolution layers for feature extraction, and its circuit diagram is shown in Figure 5As shown in the figure, the four quantum convolution layers use four sets of parameters, totaling 80 parameters. This structure takes advantage of the parallelism of quantum circuits in processing information, and can process multiple convolution feature maps in parallel on a small number of quantum bits. It is worth noting that although in amplitude coding, since the traffic sign image data has only three channels, the ground state of the channel quantum bit However, after the subsequently applied quantum channel attention layer, the ground state There will also be information in , so we cannot use only 3 quantum convolution layers.
[0094] For the classic convolution process, the feature image obtained by the convolution layer will pass through the pooling layer without learning, so that the spatial dimension of the feature image is reduced. This operation can not only reduce the computational burden, but also keep the detailed features obtained by the convolution layer.
[0095] In the quantum convolutional neural network architecture proposed in this embodiment, there is also a quantum pooling layer similar to the classical pooling, which is composed of a series of 2-qubit quantum transfer blocks. The transfer block is controlled by a parameter R x Door, digital controlled R z gate, and Pauli-X gate, such as Figure 6 The circuit structure of the transfer block shown is:
[0096] ;
[0097] Where T represents the quantum transfer block, Indicates parameterized controlled R x Door, Indicates parameterized controlled R z Door, X is Pauli-X door, is the identity matrix; The expressions for and X are as follows:
[0098] ;
[0099] .
[0100] Figure 6 For illustration only, the transfer block will control the qubits ( q 0 ) is transferred to the controlled quantum bit ( q 1 ), in the pooling layer, the transferred qubits are then discarded, achieving a dimensionality reduction similar to the classical pooling process. Rx Door and R z The gates control the quantum bits in the ground state. and When activated, the Pauli-X gate uses the information of both ground states of the quantum bit, which can retain the information more comprehensively. R x Door and R z The common use of gates represents general qubit rotations by rotations about two axes in the Bloch sphere.
[0101] The quantum pooling layer consists of a series of transfer blocks, and its circuit diagram is shown in the figure below. Figure 7 As shown (as Figure 7 For illustration only). The pooling layer here uses a symmetric double pooling structure. Unlike the general quantum pooling layer where the control qubit corresponds to the controlled qubit one by one, the information on the control qubit is pooled onto two adjacent qubits by two transfer blocks. This structure can better retain the information on the discarded qubit.
[0102] It is worth noting that another architecture of the quantum pooling layer is to measure the qubits that will be discarded, and control the activation of different rotating gates in a classical way according to the measurement results. The controlled qubits will be discarded after the pooling layer, so this architecture is equivalent to the architecture based on the controlled rotating gate. However, in the architecture proposed in this embodiment, such a choice is denied. This is because the qubits discarded in the quantum pooling layer will also be used in the quantum channel attention layer, and the quantum information therein still has its role.
[0103] Some models that use classic CNN for color image data recognition tasks have a channel attention mechanism that can calculate channel attention scores based on global information and then use them as weights to adjust the importance of feature information in different channels. This allows the model to focus on important feature information and enhance the performance of color image data recognition tasks.
[0104] Imitating the classical channel attention mechanism, this embodiment proposes a quantum channel attention layer (QCAL), whose circuit is as follows Figure 8 As shown. Fig. 9 As shown, in this embodiment, the control qubit in the quantum pooling layer is connected to the quantum channel attention layer. The control qubit first passes through a parameterized unitary element to extract the required global information. The structure of the unitary element is consistent with the structure of the quantum convolution block (that is, the first unitary element or the second unitary element). Subsequently, through a series of transfer blocks, the information on the control qubit is transferred one by one to the channel qubit.
[0105] Such a structure processes the feature qubits discarded by the quantum pooling layer, uses the contained global information to control the channel qubits, and uses them to perform weighted operations on the channel features. The purpose of this step is to emulate the channel attention mechanism in the classic CNN, generate weights for each feature channel based on global information, and use these weights to weight the features of each channel.
[0106] Since amplitude encoding is used in this embodiment, there is an entangled relationship between the feature qubit and the channel qubit. Therefore, the operation on the channel qubit is actually the operation of the amplitude of the channel feature as a whole. The purpose of this method is to make full use of global information to more accurately weight the channel features, thereby improving the model's ability to extract information between different channels.
[0107] The complete circuit structure of the quantum circuit used in this embodiment is as follows Fig.10 As shown. The encoding layer encodes the preprocessed traffic sign image data into a quantum state, and then processes it through a series of quantum controlled convolution layers, quantum pooling layers, and quantum channel attention layers. The quantum controlled convolution layers are 10-qubit, 8-qubit, and 6-qubit layers, respectively, depending on the number of discarded qubits, each of which contains 2 channel qubits. The quantum pooling layers are all 5-qubit layers, in which the selected 2 qubits are pooled onto another 3 selected qubits. The quantum channel attention layers are all 4-qubit layers, which transfer the information of the remaining 2 qubits of the pooling layer to the 2 channel qubits. This implementation sets the final required 4 feature qubits, and this embodiment performs two rounds of quantum computing layers; at the end, 2 channel qubits are discarded, and the remaining 4 feature qubits are measured to obtain classical measurement result data.
[0108] This embodiment performs a measurement on the quantum system, and the system randomly and nonlinearly collapses from the initial superposition state to a measured ground state. Through measurement, this embodiment can obtain classical information about the quantum system and understand its behavior. The four characteristic quantum bits have 16 different ground states. Measuring the four characteristic quantum bits will result in 16 different results. Since the results of quantum measurements are random, in actual quantum circuits, quantum circuits are repeatedly run, multiple measurements are performed, a series of measured ground states are obtained, and the distribution of the ground states is used as the probability distribution of the quantum measurement results.
[0109] Since the number of classification types is not necessarily the same as the number of measurement result types, this embodiment does not directly use the probability distribution of the measurement results as the classification results, but instead passes through a classic fully connected layer to project the measurement results to a space with a dimension equal to the classification type, and then passes through a softmax layer to obtain the probability distribution of the classification results, and takes the maximum value as the classification result. Since the fully connected layer is essentially a linear mapping, if the data is mapped from a low-dimensional feature space to a high-dimensional feature space, the result is at most in a subspace with the same dimension as the low-dimensional feature space, and cannot cover all the bases of the high-dimensional feature space. Therefore, the number of effective classification types cannot be higher than the number of ground states of the quantum bit, that is, a maximum of 16 categories of classification can be performed.
[0110] In the training layer, this embodiment uses cross entropy loss as the loss function for model training. Compared with the common mean square error loss function, this loss function is more suitable for the multi-classification tasks and results based on probability distribution in this article. Since quantum measurement itself is random, the result obtained is a true probability distribution, which conforms to the meaning of entropy. The calculation of cross entropy loss is shown as follows:
[0111] ;
[0112] in, K is the number of training set data, Represents the prediction using quantum convolutional neural network x k The label is the correct label y k The probability of x k is the kth training data, are the parameters of the quantum convolutional neural network, and F(.) represents the quantum convolutional neural network.
[0113] In order to optimize the parameters, it is also necessary to obtain the gradient of the loss function with respect to the parameters. The gradient calculation of the cross entropy loss is relatively simple. The calculation of the gradient is shown in the following formula:
[0114] ;
[0115] in, Represents differential calculation.
[0116] For quantum circuits, it is difficult to calculate the specific parameter gradient analytically like classical machine learning. Generally speaking, the gradient of a quantum circuit is calculated using the parameter displacement rule, which requires adjusting a single parameter and performing two additional runs to obtain the gradient. The gradient is calculated as follows, where r is the shift constant related only to the quantum gate:
[0117] ;
[0118] in, are the parameters of the quantum circuit.
[0119] Based on the obtained gradient, this embodiment uses the Adam optimizer to optimize the parameters. In addition to the momentum that changes with the gradient, , and also has a rate that changes dynamically based on the steepness of the gradient , the learning rate can be adjusted dynamically for different parameters. For hybrid quantum and classical architectures, there is a huge difference in the learning efficiency of quantum parameters and classical parameters, so it is important to assign learning rates to parameters separately. The learning rate used by the Adam optimizer The process of the Adam optimizer in this embodiment is shown in the following formula:
[0120]
[0121] in, represents the learning rate, subscript Represents the first parameters, t represents the number of iterations, m represents the momentum that changes with the gradient, v represents the rate of dynamic change according to the steepness of the gradient, , and are the basic parameters of the Adam optimizer, represents the first quantum convolutional neural network at the t+1th iteration The value of the parameter, represents the first quantum convolutional neural network at the tth iteration The value of the parameter, for v The correction value of is the corrected value of m.
[0122] During training, all 2048 training data are used once as an iteration. Each iteration is divided into 8 batches in a random order. Each batch contains 256 data. Training is performed once in parallel and the parameters are updated once. The cycle is repeated for 100 iterations to obtain the model results.
[0123] It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, the present invention will not further describe various possible combinations.
Claims
1. A traffic sign recognition method based on quantum convolutional neural network, characterized in that: The specific steps include: Step 1: Collect traffic sign images and perform label processing for each image; the collected traffic sign images and corresponding labels are used as sample data; Step 2: Establish a quantum convolutional neural network, which includes a preprocessing layer, a quantum circuit and a classification layer; The preprocessing layer preprocesses the sample data, and the preprocessing specifically includes performing a softmax-like processing on the sample data, performing amplitude encoding on the data after the softmax-like processing, obtaining C channel qubits and I1 feature qubits, and sending the obtained qubits to the quantum circuit for processing; The quantum circuit includes a quantum computing layer and an independent controlled convolution layer, the quantum computing layer includes a controlled convolution layer, a quantum pooling layer and a quantum channel attention layer, the controlled convolution layer performs a convolution operation on the input feature quantum bits, selects w feature quantum bits after the convolution operation and inputs them into the quantum pooling layer, w≤I1, and the quantum pooling layer transfers the information contained in the control quantum bit to the controlled quantum bit; then the quantum channel attention layer is used to extract the channel attention information of the control quantum bit and the channel quantum bit, and the control quantum bit is discarded; it is judged whether the preset stop condition is met, if not, the output of the current quantum computing layer is input into the next quantum computing layer until the preset stop condition is met, if yes, the output of the current quantum computing layer is input into an independent controlled convolution layer, and the output of the independent controlled convolution layer is used as the output of the quantum circuit; and the output of the quantum circuit is input into the classification layer; The classification layer outputs the classification result of the traffic sign; Step 3: Train the quantum convolutional neural network and use the trained quantum convolutional neural network for traffic sign recognition; In step 2, the softmax class uses the following formula to process the sample data: Among them, M represents the temperature of the class softmax, x represents the N-dimensional sample data vector, and x i represents the i-th pixel of vector x; i = 1, 2, ..., N; j1 = 1, 2, ..., N; p is a multi-channel data vector with N pixels and C channels processed by the softmax class, p i represents the i-th pixel of vector p; The expression of the amplitude coding is as follows: Among them, pi+NC represents the value of the cth channel of the i-th pixel of vector p; U(.) represents the amplitude coding function, |c> represents the ground state of the channel quantum bit, and |i> represents the ground state of the characteristic quantum bit.
2. A traffic sign recognition method based on quantum convolutional neural network according to claim 1, characterized in that: The stop condition preset in step 2 is that the number of characteristic quantum bits output by the current quantum computing layer meets the preset number.
3. A traffic sign recognition method based on quantum convolutional neural network according to claim 1, characterized in that: The controlled convolutional layer consists of two sequentially connected C quantum convolution layer, using the ground state control of the channel qubit 2 C Whether a quantum convolution layer is used, one ground state controls one quantum convolution layer; each quantum convolution layer has the same structure, including I1 / 2 first unitary elements with 2 quantum bits and (I1-2) / 2 second unitary elements with 2 quantum bits, the 11 characteristic quantum bits are combined in pairs in sequence to obtain I1 / 2 characteristic quantum bit groups, which are input into the corresponding first unitary element, and the outputs of all the first unitary elements corresponding to the first characteristic quantum bit and the outputs corresponding to the 11th characteristic quantum bit are directly used as the first output and I1th output of the quantum convolution layer, and the remaining outputs of all the first unitary elements are combined again in pairs to obtain (I1-2) / 2 output groups, which are input into the corresponding second unitary element.
4. A traffic sign recognition method based on quantum convolutional neural network according to claim 3, characterized in that: The first and second unitary elements have the same structure but different parameters; the structure CB(θ) of the unitary element is as follows: Among them, Θ represents the parameter of the unitary element, R x (θ1), R x (θ2), R x (θ7) and R x (θ8) is the first to fourth parameterized R with parameters θ1, θ2, θ7, θ8 x Door, R z (θ3), R z (θ4), R z (θ9) and R z (θ 10 ) are parameters θ3, θ4, θ9, θ 10 The first to fourth parameterizations R z Door, CR x (θ5), CR xr (θ6) is the first and second parameterized controlled R with parameters θ5 and θ6 x Door, represents tensor product; First to fourth parameterization R x The gate structure is the same, and the corresponding matrix form R x (θ1) is as follows: Among them, θ1 is the parameterized R x The parameter of the gate, j is the imaginary unit; First to fourth parameterization R z The gate structure is the same, and the corresponding matrix form R z (θ2) is as follows: Among them, θ2 is the parameterized R z Parameters of the door; The first and second parameterized controlled R x The gate structure is the same, and the corresponding matrix form CR x (θ3) is as follows: Where θ3 is the parameterized controlled R x Parameters of the door.
5. A traffic sign recognition method based on quantum convolutional neural network according to claim 4, characterized in that: The quantum channel attention layer inputs the control qubit into the third unitary element, and transfers the information contained in the output of the third unitary element to the channel qubit through a 2-qubit quantum transfer block. The structure of the third unitary element is the same as that of the first and second unitary elements. The expression of the quantum transfer block is as follows: Where T represents the quantum transfer block, CR x Represents parameterized controlled R x Door, CR z Represents parameterized controlled R z Door, X is the Pauli-X gate, I is the identity matrix; CR z The expressions for and X are as follows: in, Represents parameterized controlled R z Parameters of the door.
6. A traffic sign recognition method based on quantum convolutional neural network according to claim 5, characterized in that: The quantum pooling layer adopts a symmetric dual-pooling structure, including a plurality of 2-qubit quantum transfer blocks. The quantum pooling layer uses the quantum transfer block to transfer the information contained in the control quantum bit to the controlled quantum bit adjacent to the control quantum bit.
7. The traffic sign recognition method based on quantum convolutional neural network according to claim 1 is characterized in that: The cross entropy loss is used as the loss function during training. The expression of the cross entropy loss L is as follows: Among them, K is the number of training set data, P(F(x k ,θ F )=y k ) indicates the use of quantum convolutional neural network to predict x k The label is the correct label y k The probability of x k is the kth training data, θ F are the parameters of the quantum convolutional neural network, and F(.) represents the quantum convolutional neural network.
8. A traffic sign recognition method based on quantum convolutional neural network according to claim 7, characterized in that: The gradient of cross entropy is calculated using the following formula: in, Indicates differential calculation; The parameter θ of the quantum circuit f The gradient of is calculated using the following formula: Where r is the shift constant associated with the quantum gate.
9. A traffic sign recognition method based on quantum convolutional neural network according to claim 7, characterized in that: The Adam optimizer is used to optimize the parameters: Where η represents the learning rate, the subscript g represents the gth parameter in the quantum convolutional neural network, t represents the number of iterations, m represents the momentum that changes with the gradient, v represents the rate that changes dynamically according to the steepness of the gradient, β1, β2 and ∈ are the basic parameters of the Adam optimizer, θ g,t+1 represents the value of the gth parameter in the quantum convolutional neural network at the t+1th iteration, θ g,t represents the value of the gth parameter in the quantum convolutional neural network at the tth iteration, is the corrected value of v, is the corrected value of m.
Citation Information
Patent Citations
Array type air pressure measurement compensation device and method based on quantum particle swarm wavelet neural network
CN105258839A
Traffic sign recognition method and system based on convolutional neural network
CN111199217A
Emotion analysis method and device based on aspect attention and convolutional memory neural network
CN111881260A
Neural network macro architecture searching method and system based on attention mechanism
CN114742199A
EEG data classification method of hybrid convolutional neural network based on classical quantum
CN118035843A
