A quantum transfer learning method
By introducing quantum convolutional neural network module into deep learning models, combined with the advantages of quantum computing, the problems of long training time and insufficient performance of deep learning models are solved, and more efficient image classification task performance is achieved.
Patent Information
- Application Number
- CN202411148997.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-21
- Publication Date
- 2024-11-22
- Estimated Expiration
- 2044-08-21
AI Technical Summary
Deep learning models have a long training time and insufficient performance in image classification tasks. The existing transfer learning methods rely on defining feature extractors during feature extraction, and traditional convolutional neural networks have limited performance on specific tasks.
Using quantum transfer learning method, by introducing quantum convolutional neural network modules into ResNet18 and ResNet34 networks, combined with the advantages of quantum computing, it reduces model training time and improves performance. Specific steps include data preprocessing, deleting the average pooling layer and fully connected layer in the network, adding quantum convolutional layer, and using quantum logic gates and circuits for feature extraction and classification.
显著减少了模型训练时间,提高了模型在图像分类任务上的准确率,量子迁移学习模型在特定数据集上的表现优于经典模型,准确率提高0.09%到0.28%。
Smart Images

Figure CN118657226B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer vision technology, and in particular to a quantum transfer learning method. Background Art
[0002] Currently, when training deep learning models, researchers often use transfer learning to accelerate model training. Since the model structure of deep learning is generally large, using transfer learning can effectively avoid training the model from scratch, thereby reducing the training time of the model, and by importing better parameters into the model before training, the performance of the model can be improved. Assuming that an image classification task is now required, when extracting image features, there is no need to define a feature extractor. Instead, you can use a trained backbone, such as ResNet, VGG, and other networks, and optimize only the last few layers on specific tasks and data sets of interest, so as to achieve the purpose of accelerating model training.
[0003] Quantum computing can use quantum neural networks to model and train deep learning models. Quantum neural networks use quantum bits and quantum gates to represent and process data, which can better simulate and utilize the properties of quantum systems, thereby improving the performance and efficiency of the model. Quantum neural networks have shown better performance than classical neural networks in certain specific tasks. Due to the great success of convolutional neural networks in deep learning feature extraction, coupled with the advantages of quantum computing over traditional computing, more and more researchers are exploring the use of quantum circuits to build quantum convolutional neural network structures to replace traditional convolutional neural network structures. Summary of the invention
[0004] Purpose of the invention: The purpose of the present invention is to provide a quantum transfer learning method, which uses the idea of transfer learning to adjust the existing model to avoid training the model from scratch, thereby significantly reducing the training time. At the same time, the present invention combines the advantages of quantum computing to improve the performance and efficiency of the model.
[0005] Technical solution: A quantum transfer learning method described in the present invention comprises the following steps:
[0006] (1) Obtain the data of the Flowers Recognition dataset and the Animal-10 dataset and perform preprocessing;
[0007] (2) Construct the ResNet18 quantum transfer learning model and the ResNet34 quantum transfer learning model, that is, introduce quantum convolutional neural network modules into the ResNet18 network and the ResNet34 network respectively;
[0008] (3) The ResNet18 quantum transfer learning model and the ResNet34 quantum transfer learning model were trained respectively, and compared with the original ResNet18 and ResNet34 models.
[0009] Furthermore, step (1) is as follows: the size of the data is enlarged to 256×256 pixels, the size is cropped to 224×224 pixels using center cropping, and finally standardized. The preprocessed image size is 224×224×3 pixels, so that the input image conforms to the standard input format of the ResNet network.
[0010] Furthermore, step (2) is as follows: first, delete the last average pooling layer and the fully connected layer in the ResNet18 network and the ResNet34 network, and then add a convolutional layer, i.e., a quantum convolutional neural network module, after the ResNet18 network and the ResNet34 network.
[0011] Furthermore, the quantum convolutional neural network module is composed of 8 quantum convolutional layer circuits with the same structure, which are used to obtain a convolutional feature map with 8 channels; among them, the quantum convolutional layer circuit is composed of 6 quantum logic gate combination structures; when the sliding window is fixed to 2×2, the number of channels of the feature map is 16.
[0012] Furthermore, the quantum logic gate formula is as follows:
[0013] ;
[0014] in, represents a quantum logic gate, I represents the unit matrix, , Represents two U 3 Gate; θ 7 ,θ 8 ,θ 9 Both represent the control of the rotation angle on the Bloch sphere; CNOT 0 represents a CNOT gate; R y () indicates R y Door; R z () indicates R z Door;
[0015] Since the parameters of the first five quantum logic gate combination structures are the same, the quantum convolution layer circuit operation matrix expression formula is as follows:
[0016] ;
[0017] in, represents a quantum logic gate, represents the first five quantum logic gate combinations; Represents the sixth quantum logic gate.
[0018] Beneficial effects: Compared with the prior art, the present invention has the following significant advantages: integrating quantum computing with transfer learning, so that the quantum transfer learning model can achieve better performance or speed than the classical model. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 This is a structural diagram of a multi-channel quantum convolutional neural network model of the present invention;
[0020] Figure 2 The design diagram of the quantum logic gate of the present invention;
[0021] Figure 3 A circuit diagram of a quantum convolution layer circuit of the present invention;
[0022] Figure 4 This is a comparison chart of the prediction accuracy of the ResNet18 quantum transfer learning model and the ResNet18 classic model in the patent of this invention on the Flowers Recognition training set and test set;
[0023] Figure 5 This is a comparison chart of the prediction accuracy of the ResNet34 quantum transfer learning model in the patent of this invention and the ResNet34 classic model on the Animal-10 training set and test set. DETAILED DESCRIPTION
[0024] The technical solution of the present invention is further described below in conjunction with the accompanying drawings.
[0025] like Figure 1 As shown, an embodiment of the present invention provides a quantum transfer learning method, comprising the following steps:
[0026] (1) Obtain data from the Flowers Recognition dataset and the Animal-10 dataset and perform preprocessing. Specifically, enlarge the size of the data to 256 × 256 pixels, crop it to 224 × 224 pixels using center cropping, and finally standardize it. The preprocessed image size is 224 × 224 × 3 pixels, so that the input image conforms to the standard input format of the ResNet network.
[0027] (2) Constructing the ResNet18 quantum transfer learning model and the ResNet34 quantum transfer learning model, that is, introducing quantum convolutional neural network modules into the ResNet18 network and the ResNet34 network respectively; Figure 1As shown in the figure, the details are as follows: delete the last average pooling layer and the fully connected layer in the ResNet18 network and the ResNet34 network, and then add a convolution layer, that is, a quantum convolutional neural network module, after the ResNet18 network and the ResNet34 network; the specific process is as follows: input the image into the convolution layer of ResNet18 or ResNet34 to extract the high-level features of the image, and perform multi-level feature extraction on the input image through multiple convolutional layers and residual modules to generate a feature map of size 7×7×512, and add a quantum convolutional neural network module after the ResNet network to reduce the dimension of the feature map to a 3×3×16 feature map suitable for the size of the multi-channel quantum convolutional neural network, and then add a fully connected layer for image classification, and train and update the parameters of the entire network through cross entropy loss function calculation and back propagation algorithm. Among them, the quantum convolutional neural network module is composed of 8 quantum convolutional layer circuits with the same structure; it is used to obtain a convolutional feature map with 8 channels; among them, the quantum convolutional layer circuit is composed of a combination structure of 6 quantum logic gates; the sliding window is fixed to 2×2, and the number of channels of the feature map is 16.
[0028] like Figure 3 As shown, the quantum logic gate is as follows: Assume that the initial input state of 6 quantum bits is:
[0029] ;
[0030] in, Ψ 0 , Ψ 1 , Ψ 2 , Ψ 3 , Ψ 4 , Ψ 5 They represent quantum bits respectively;
[0031] The quantum logic gate formula is as follows:
[0032] ;
[0033] in, represents a quantum logic gate, I represents the unit matrix, , Represents two U 3 Gate, θ 7 ,θ 8 ,θ 9 Both represent the control of the rotation angle on the Bloch sphere; CNOT 0 represents a CNOT gate; R y () indicates R y Door; Rz () indicates R z Door;
[0034] like Figure 2 As shown, in quantum circuits, the direction of the circuit is usually expressed from right to left. The two quantum bits first pass through the U3 gate. The product calculation of the two U3 gates is expressed by the following formula:
[0035] ;
[0036] Its matrix expression is:
[0037] ;
[0038] Any single-qubit gate can be decomposed into a combination of several basic rotation gates, which can be converted into a combination of Ry and Rz gates according to the U3 gate matrix expression, namely:
[0039] ;
[0040] Since the parameters of the first five quantum logic gate combination structures are the same, the quantum convolution layer circuit operation matrix expression formula is as follows:
[0041] ;
[0042] in, represents a quantum logic gate, represents the first five quantum logic gate combinations; Represents the sixth quantum logic gate.
[0043] When the operation of the six quantum logic gate combination structure is completed, the state of the quantum convolution layer circuit is:
[0044] .
[0045] in, Figure 2 In, θ 1 , ,λ 3 ,θ 4 , ,λ 6 ,θ 10 , ,λ 12 ,θ 13 , ,λ 15 ,θ 7 ,θ 8 ,θ 9 They respectively represent the rotation angle on the control Bloch sphere.
[0046] (3) The ResNet18 quantum transfer learning model and the ResNet34 quantum transfer learning model were trained respectively, and compared with the original ResNet18 and ResNet34 models. The details are as follows: Figure 4 As shown in the figure, the comparison between the ResNet18 quantum transfer learning model and the ResNet18 classic model is used. The Flowers Recognition dataset has a total of 4317 flower images. The dataset is divided into 80% as a training set and 20% as a test set. 3453 images are used as training sets and 864 images are used as test sets. The Flowers Recognition dataset has five kinds of flower data. On the test set, the highest accuracy of the ResNet18 quantum transfer learning model is 0.8805, which is 0.09% higher than the highest accuracy of the ResNet18 classic model of 0.8796.
[0047] like Figure 5 As shown in the figure, the comparison between the ResNet34 quantum transfer learning model and the ResNet34 classic model is based on the Animal-10 dataset, which contains approximately 26,000 animal images. The dataset is divided into 80% as a training set and 20% as a test set, so 20,943 images are used as a training set and 5,236 images are used as a test set. On the test set, the highest accuracy of the ResNet34 quantum transfer learning model is 0.9496, which is 0.28% higher than the highest accuracy of the ResNet34 classic model of 0.9468.
Claims
1. A quantum transfer learning method, It is characterized in that The following steps are involved: (1) Obtain the data of the Flowers Recognition dataset and the Animal-10 dataset and preprocess them as follows: enlarge the size of the data to 256×256 pixels, crop it to 224×224 using center cropping, and finally standardize it. The preprocessed image size is 224×224×3 pixels, so that the input image conforms to the standard input format of the ResNet network; (2) Construct the ResNet18 quantum transfer learning model and the ResNet34 quantum transfer learning model, that is, introduce quantum convolutional neural network modules into the ResNet18 network and the ResNet34 network respectively; specifically as follows: first, delete the last average pooling layer and the fully connected layer in the ResNet18 network and the ResNet34 network, and then add a convolution layer, that is, a quantum convolutional neural network module, after the ResNet18 network and the ResNet34 network; wherein, the quantum convolutional neural network module is composed of 8 quantum convolutional layer circuits with the same structure, which are used to obtain a convolutional feature map with 8 channels; wherein, the quantum convolutional layer circuit is composed of a combination structure of 6 quantum logic gates; fix the sliding window to 2×2, then the number of channels of the feature map is 16; the quantum logic gate is as follows: suppose the initial input 6 quantum bit states are: ; in, Ψ 0 , Ψ 1 , Ψ 2 , Ψ 3 , Ψ 4 , Ψ 5 They represent quantum bits respectively; The quantum logic gate formula is as follows: ; in, represents a quantum logic gate, I represents the unit matrix, , Represents two U 3 Gate, θ 7 ,θ 8 ,θ 9 Both represent the control of the rotation angle on the Bloch sphere; CNOT 0 represents a CNOT gate; R y () indicates R y Door; R z () indicates R z Door; In the quantum circuit, the direction of the circuit is represented from right to left. The two quantum bits first pass through the U3 gate. The product calculation of the two U3 gates is expressed by the following formula: ; Among them, θ 1 , ,λ 3 ,θ 4 , ,λ 6 They respectively represent the rotation angles on the controlled Bloch sphere; The matrix expression is: ; Any single-qubit gate is decomposed into a combination of several basic rotation gates, which can be transformed into a combination of Ry and Rz gates according to the U3 gate matrix expression, namely: ; Since the parameters of the first five quantum logic gate combination structures are the same, the quantum convolution layer circuit operation matrix expression formula is as follows: ; in, represents a quantum logic gate, represents the first five quantum logic gate combinations; represents the sixth quantum logic gate; When the operation of the six quantum logic gate combination structure is completed, the state of the quantum convolution layer circuit is: ; (3) The ResNet18 quantum transfer learning model and the ResNet34 quantum transfer learning model were trained respectively, and compared with the original ResNet18 and ResNet34 models.
