Image classification model design method based on quantum convolutional neural network
By designing a quantum convolution kernel containing coding modules and entangled modules in a quantum convolution neural network, and combining the fully connected layer and the PennyLane framework to adjust the model parameters, the problem of insufficient efficiency and feature extraction capabilities of the quantum convolution neural network model in image classification is solved, and efficient image classification and model performance optimization is achieved.
Patent Information
- Application Number
- CN202411702558.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-26
- Publication Date
- 2025-03-25
AI Technical Summary
The existing quantum convolutional neural network models are not efficient when encoding image data into quantum states, their feature extraction capabilities are limited, and their effective tuning strategies are lacking, resulting in complex and inefficient model performance optimization process.
The quantum convolution layer is designed, and its quantum convolution kernel includes a coding module and a trainable entanglement module. The image data is encoded through the Hadamard gate and the parameterized RY gate, and the entangled states between quantum bits are generated through the entanglement module. The initial image classification model is constructed in combination with the fully connected layer, and the depth and width of the quantum convolutional layer are adjusted through the PennyLane quantum machine learning framework to optimize model performance.
It improves the coding efficiency and feature extraction ability of image data, simplifies the model tuning process, significantly improves the classification accuracy of the image classification model, and avoids excessive increase in model overfitting and computational complexity.
Smart Images

Figure CN119693685A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image classification, and in particular to a method for designing an image classification model based on a quantum convolutional neural network. Background Art
[0002] In the field of image classification, traditional deep learning methods have achieved remarkable results, but with the increase in data volume and model complexity, these methods have an increasing demand for computing resources and training time. As an emerging computing paradigm, quantum computing, with its unique quantum properties such as superposition and entanglement, provides new possibilities for dealing with complex problems. As a new type of quantum machine learning model, the design and implementation of quantum convolutional neural network can take advantage of quantum computing to improve the efficiency and accuracy of image classification. However, the existing quantum convolutional neural network model design methods have the following technical defects: when encoding image data into quantum states, the efficiency is not high, resulting in limited feature extraction capabilities; when generating entangled states between quantum bits, the existing methods are difficult to effectively utilize quantum state image data, affecting the extraction of high-level features; when adjusting model parameters to improve classification accuracy, the existing quantum convolutional neural network models lack effective tuning strategies, making the model performance optimization process complex and inefficient. Summary of the invention
[0003] The present invention provides an image classification model design method based on quantum convolutional neural network, which can solve the above problems.
[0004] In order to solve the above problems, the technical solution adopted by the present invention is as follows:
[0005] The present invention provides an image classification model design method based on quantum convolutional neural network, comprising the following steps:
[0006] S1. Design a quantum convolution layer, whose quantum convolution kernel includes an encoding module and a trainable entanglement module. The encoding module is used to encode the input image data into a quantum state, and the entanglement module is used to generate an entangled state between quantum bits using the quantum state image data to obtain high-level features of the image;
[0007] S2. Combine the quantum convolution layer with the fully connected layer to form an initial image classification model, where the fully connected layer is used to classify the high-level features of the image through a nonlinear activation function;
[0008] S3, based on the PennyLane quantum machine learning framework, using the target class standard image classification dataset as the input of the initial image classification model, adjusting the depth of the quantum convolution layer to maximize the classification accuracy of the initial image classification model;
[0009] S4, based on the PennyLane quantum machine learning framework, using the target class standard image classification dataset in step S3 as the input of the initial image classification model, adjusting the width of the quantum convolution layer to maximize the classification accuracy of the initial image classification model;
[0010] S5. Adjust the depth and width of the initial image classification model to the depth determined in step S3 and the width determined in step S4, respectively, to obtain a final image classification model.
[0011] As a further description of the above technical solution: when classifying the input image data, the quantum convolution kernel traverses the entire image according to a certain receptive field size and stride.
[0012] As a further description of the above technical solution: the encoding module encodes the input image data based on the Hadamard gate and the parameterized RY gate, and the encoding formula is:
[0013]
[0014] Among them, θ i is the rotation angle of the quantum bit, x i is the input image feature value, and i is the sequence number of the input image feature value.
[0015] As a further description of the above technical solution: the entanglement module generates an entangled state between quantum bits by interleaving the image data of the quantum state using a controlled rotating Z gate and a parameterized RY gate, wherein:
[0016] The entangled state obtained by controlling the rotating Z gate is expressed as:
[0017]
[0018] Among them, θ i1 is the rotation angle of each input feature in the Z gate, σ z 1 and σ z 2 is the Pauli Z matrix acting on the two qubits;
[0019] The entangled state obtained by parameterizing the RY gate is expressed as:
[0020]
[0021] Among them, σ y is the Pauli Y matrix acting on the qubit, θ i2 is the rotation angle of each input feature in the RY gate.
[0022] As a further description of the above technical solution: the nonlinear activation function used by the fully connected layer is the ReLU function.
[0023] As a further description of the above technical solution: the fully connected layer optimizes the classification results through the cross entropy loss function to minimize the difference between the model prediction results and the true labels.
[0024] As a further description of the above technical solution: the depth of the quantum convolution layer is controlled by superimposing multiple entanglement modules, and the width of the quantum convolution layer is adjusted by adjusting the number of quantum bits in the quantum convolution kernel.
[0025] As a further description of the above technical solution: the target class standard image classification data set is the handwritten digits {1, 7, 9} in the MNIST data set.
[0026] Compared with the prior art, the present invention has the following beneficial effects:
[0027] By designing a quantum convolution kernel including a coding module and a trainable entanglement module, the present invention can efficiently encode input image data into a quantum state, thereby improving the efficiency of feature extraction; by using quantum state image data to generate an entangled state between quantum bits, the present invention can extract high-level features of the image, thereby enhancing the feature extraction capability of the model; based on the PennyLane quantum machine learning framework, the present invention can adjust the depth and width of the quantum convolution layer to optimize the classification accuracy of the initial image classification model, thereby simplifying the model tuning process; by adjusting the depth and width of the quantum convolution layer, the present invention can maximize the classification accuracy of the initial image classification model, thereby improving the performance of the model; by adjusting the depth and width of the quantum convolution layer, and combining the entanglement and nonlinear characteristics of the quantum circuit, an image classification model based on a quantum convolutional neural network suitable for different target tasks can be designed.
[0028] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the embodiments of the present invention are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0030] Figure 1 It is a schematic diagram of the overall architecture of the quantum convolutional neural network in the embodiment;
[0031] Figure 2 Schematic diagram of the operation of the entanglement module in the quantum convolution layer in the embodiment;
[0032] Figure 3 It is a schematic diagram of the quantum convolution layer depth analysis model in the embodiment;
[0033] Figure 4 Schematic diagram of the quantum convolution layer width analysis model in the embodiment;
[0034] Figure 5 It is a schematic diagram of the final model proposed according to the multi-dimensional strategy in the embodiment. DETAILED DESCRIPTION
[0035] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments.
[0036] This embodiment discloses a method for designing an image classification model based on a quantum convolutional neural network, comprising the following steps:
[0037] S1. Design quantum convolution layer.
[0038] When designing a quantum convolutional neural network, the quantum convolution kernel of the quantum convolutional layer will traverse the entire image according to a certain receptive field size and stride to ensure effective coverage of the entire input image. Compared with traditional CNNs, quantum convolutional neural networks use a unique internal calculation process. The quantum convolution kernel of the quantum convolutional layer includes an encoding module and a trainable entanglement module. For example, in deep learning, a common convolutional layer configuration is a convolution kernel size of 3x3, a stride of 1, and no padding (padding is 0). In this case, the receptive field of each neuron in the first convolutional layer is 3x3 because it is affected by the convolution kernel of size 3x3. If the convolution kernel size of the second convolutional layer is also 3x3, the stride is 1, and there is no padding, then the receptive field of the second layer of neurons is 5x5, because it operates on the output of the first layer. Through mapping, it can be seen that the receptive field of the second layer of neurons has expanded to 5x5. This configuration is also feasible in the quantum convolution layer, where the encoding module of the quantum convolution kernel encodes the digitized image information into the quantum state of the quantum bit (qubit), and the gate operation of the entanglement module contains trainable weights, and the evolved quantum state is measured to derive the classical output.
[0039] The encoding module is responsible for converting the data into a quantum state. In order to achieve this conversion, in addition to the Hadamard gate, this embodiment also uses a parameterized RY gate to encode the input image data, that is, the data is mapped by adjusting the rotation angle of the RY gate. Specifically, assuming that the input image data is x = [x0, x1, ..., x n-1 ], where n is the number of input eigenvalues. For each input image eigenvalue x i , which can be encoded as the rotation angle θ of the quantum bit through formula (1) i ,
[0040]
[0041] In formula (1), the range of input eigenvalues is mapped from 0 to 255 to 0 to π.
[0042] The Hadamard gate is a single-qubit gate that maps a qubit from a computational ground state (|0> or |1>) to a superposition state of equal probability. This is achieved through the matrix of the Hadamard gate, which is in the form of:
[0043]
[0044] This gate can create a uniform superposition state, providing an equally probabilistic starting point for subsequent quantum calculations.
[0045] The rotation of the RY gate can introduce necessary nonlinear characteristics to the quantum state by adjusting the rotation angle. Through the nonlinear rotation of the RY gate, the model can capture more complex patterns and features, thereby improving the expressive power of the quantum convolution kernel.
[0046] The entanglement module generates entangled states between quantum bits by interleaving the controlled rotation Z gate (CRZ) and the RY gate to obtain high-level features of the image. The purpose of introducing the CRZ gate is to enhance the expressive power of the quantum convolution kernel so that it can capture more complex feature relationships. The operation of the CRZ gate changes the coherence of the quantum state by applying conditional rotation to a group of quantum bits, thereby further introducing complex quantum correlations. The entangled state obtained by the controlled rotation Z gate (CRZ) is expressed by formula (3), and the entangled state obtained by the RY gate is expressed by formula (4):
[0047]
[0048] Among them, σ z 1 and σ z 2 is the Pauli Z matrix acting on the two qubits, θ i1 is the rotation angle of each input feature in the Z gate;
[0049]
[0050] Among them, σ y is the Pauli Y matrix acting on the qubit, θ i2 is the rotation angle of each input feature in the RY gate.
[0051] Through this entanglement process, the quantum convolutional neural network model can effectively utilize the characteristics of quantum superposition and entanglement to improve the ability to extract complex image features, which is difficult to achieve with classical convolutional neural networks. Figure 2 The quantum convolution kernel structure described in this embodiment is shown in FIG. 1 , in which a single encoding method is used to convert a single classical data x i Encoded into a quantum bit, thus realizing the quantized representation of data.
[0052] After the entanglement operation, each quantum bit of the quantum convolution layer is output as a feature map channel for processing by the subsequent fully connected layer.
[0053] S2, combine the quantum convolution layer with the fully connected layer to form the initial image classification model, such as Figure 1 As shown, the fully connected layer is used to classify the high-level features of the image through a non-linear activation function.
[0054] The quantum convolution layer extracts high-level features of the input image through parameterized quantum gates. After the output of the quantum convolution layer, the fully connected layer is used to map the quantum features to a specific classification space. The fully connected layer processes and classifies the extracted quantum features through a nonlinear activation function (ReLU function) to increase the nonlinear fitting ability of the network, enhance the classification performance, and avoid the gradient vanishing problem in deep neural networks, as shown in formula (5):
[0055] ReLU(x)=ma(x0,x) (5)
[0056] Here, x represents the input value in the neural network, and the ReLU function truncates all input values less than zero to zero, while retaining values greater than or equal to zero unchanged.
[0057] In this embodiment, the fully connected layer optimizes the classification results through the cross entropy loss function to minimize the difference between the model prediction results and the true labels.
[0058] S3. Adjust the depth of the quantum convolution layer.
[0059] In this embodiment, the depth of the quantum convolution layer in the quantum convolution neural network model (deep test image classification model, i.e., changing the number of quantum convolution layers based on the initial image classification model) is controlled by the number of entanglement modules, such as Figure 3 As shown in Figure 2, the handwritten digits {1, 7, 9} in the MNIST dataset are used as input data for the classification target task, and the dataset samples are grayscale images of 14×14 pixels.
[0060] The depth of the quantum convolution layer is set to 2, 4, 6, and 8 layers, and the number of quantum bits is fixed to 4. The PennyLane quantum machine learning framework is used to adjust the depth of the entanglement module to observe its impact on the image classification accuracy. The experimental results show that as the depth of the quantum convolution layer increases, the classification accuracy of the image classification model first increases and then decreases, which is different from the linear growth or decline trend described in the prior art. Table 1 shows the impact of quantum convolution layers of different depths on the model classification accuracy.
[0061] Table 1
[0062] Entanglement module depth (number of layers) Accuracy (%) Standard Deviation 95% confidence interval (%) 2 90.05 0.34 89.71-90.39 4 94.38 0.29 94.09-94.67 6 95.42 0.13 95.29-95.55 8 34.58 1.12 33.46-35.70
[0063] It can be seen from the results that when the number of entanglement module layers is 6, the classification accuracy of the image classification model is the highest, reaching 95.42%, so the depth of the quantum convolution layer determined in this embodiment is 6 layers. When the depth increases to 8 layers, the accuracy of the image classification model drops significantly to 34.58%, which indicates that too deep quantum convolution layers introduce too much complexity, resulting in overfitting or decreased generalization ability of the model.
[0064] S4. Adjust the width of the quantum convolution layer.
[0065] In this embodiment, the width of the quantum convolution layer in the quantum convolution neural network model (width test image classification model, i.e., changing the number of quantum bits based on the initial image classification model) is achieved by adjusting the number of quantum bits in the quantum convolution kernel, such as Figure 4 As shown in the figure, the depth of the fixed entanglement module is 2 layers. The number of quantum bits is set to 2, 3, and 4 respectively, and classification experiments are performed on the same dataset, that is, the handwritten digits {1, 7, 9} in the MNIST dataset are used as the input data of the classification target task, and the dataset samples are 14×14 pixel grayscale images.
[0066] The experimental results show that as the number of quantum bits increases, the classification accuracy of the model first increases and then decreases. When the number of quantum bits is 3, the classification performance of the model is the best, with an accuracy of 95.42%. Therefore, the width of the quantum convolution layer determined in this embodiment is 3, that is, the number of quantum bits is set to 3. Table 2 shows the effect of quantum convolution layers of different widths on the classification accuracy of the model.
[0067] Table 2
[0068] Number of qubits Accuracy (%) Standard Deviation 95% confidence interval (%) 2 92.92 0.45 92.47-93.37 3 95.42 0.28 95.14-95.70 4 90.05 0.34 89.71-90.39
[0069] As can be seen from Table 2, too many qubits (4) increase the complexity of the image classification model, resulting in performance degradation. However, the configuration of 3 qubits achieves the best feature extraction capability, allowing the image classification model to achieve the highest accuracy in the image classification task.
[0070] S5. Build the final image classification model
[0071] In this embodiment, a multi-dimensional optimization strategy is proposed by combining the best performing parameter configurations in the aforementioned depth and width experiments. When the depth of the quantum convolution layer is 6 layers and the number of quantum bits is 3, the classification performance of the image classification model reaches 96.67%, which is significantly higher than the results of single depth or width optimization, that is, the final image classification model, such as Figure 5 As shown, the depth of the quantum convolution layer is 6 layers and the number of quantum bits is 3. Table 3 shows the model performance after the optimization analysis of depth and width.
[0072] Table 3
[0073] Configuration Quantum convolution layer depth Number of qubits Accuracy Combination 1 2 3 95.42 Combination 2 6 3 96.67 Combination 3 6 4 95.42
[0074] It can be seen from experimental analysis that the image classification model designed by this embodiment can effectively improve the learning ability and accuracy in the image classification target task.
[0075] The present invention achieves more efficient image classification performance by systematically analyzing and optimizing the depth and width of the quantum convolutional neural network. Experimental results show that the optimal combination of quantum convolution layer depth and width can be obtained based on the method of the present invention, which can avoid model overfitting and excessive increase in computational complexity while ensuring a high accuracy rate. In specific applications, this analysis method is particularly suitable for the extraction and classification of complex image features and has broad application prospects.
[0076] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for designing an image classification model based on a quantum convolutional neural network, characterized in that: The following steps are involved: S1. Design a quantum convolution layer, whose quantum convolution kernel includes an encoding module and a trainable entanglement module. The encoding module is used to encode the input image data into a quantum state, and the entanglement module is used to generate an entangled state between quantum bits using the quantum state image data to obtain high-level features of the image; S2. Combine the quantum convolution layer with the fully connected layer to form an initial image classification model, where the fully connected layer is used to classify the high-level features of the image through a nonlinear activation function; S3, based on the PennyLane quantum machine learning framework, using the target class standard image classification dataset as the input of the initial image classification model, adjusting the depth of the quantum convolution layer to maximize the classification accuracy of the initial image classification model; S4, based on the PennyLane quantum machine learning framework, using the target class standard image classification dataset in step S3 as the input of the initial image classification model, adjusting the width of the quantum convolution layer to maximize the classification accuracy of the initial image classification model; S5. Adjust the depth and width of the initial image classification model to the depth determined in step S3 and the width determined in step S4, respectively, to obtain a final image classification model.
2. The image classification model design method based on quantum convolutional neural network according to claim 1 is characterized in that: When classifying the input image data, the quantum convolution kernel traverses the entire image according to a certain receptive field size and stride.
3. The image classification model design method based on quantum convolutional neural network according to claim 1 is characterized in that: The encoding module encodes the input image data based on the Hadamard gate and the parameterized RY gate, and the encoding formula is: Among them, θ i is the rotation angle of the quantum bit, x i is the input image feature value, and i is the sequence number of the input image feature value.
4. The image classification model design method based on quantum convolutional neural network according to claim 3 is characterized in that: The entanglement module generates an entangled state between quantum bits by interleaving the image data of the quantum state using a controlled rotating Z gate and a parameterized RY gate, wherein: The entangled state obtained by controlling the rotating Z gate is expressed as: Among them, θ i1 is the rotation angle of each input feature in the Z gate, and is the PauliZ matrix acting on two qubits; The entangled state obtained by parameterizing the RY gate is expressed as: Among them, σ y is the Pauli Y matrix acting on the qubit, θ i2 is the rotation angle of each input feature in the RY gate.
5. The image classification model design method based on quantum convolutional neural network according to claim 1 is characterized in that: The nonlinear activation function used by the fully connected layer is the ReLU function.
6. The image classification model design method based on quantum convolutional neural network according to claim 1 is characterized in that: The fully connected layer optimizes the classification results through the cross entropy loss function to minimize the difference between the model prediction results and the true labels.
7. The image classification model design method based on quantum convolutional neural network according to claim 1 is characterized in that: The depth of the quantum convolution layer is controlled by superimposing a plurality of the entanglement modules, and the width of the quantum convolution layer is adjusted by adjusting the number of quantum bits in the quantum convolution kernel.
8. The image classification model design method based on quantum convolutional neural network according to claim 1 is characterized in that: The target class standard image classification dataset is the handwritten digits {1, 7, 9} in the MNIST dataset.
Citation Information
Cited By
Brand-new quantum intelligent calculation method specially designed for smart city
CN119918689A
Federal learning method based on quantum transfer learning
CN120975252A
Quantum fuzzy neural network adaptive to high-dimensional input and classification method
CN121303194A