A quantum convolution classification method based on attention enhancement and supervised contrast learning
Patent Information
- Application Number
- CN202611006374.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-07
- Publication Date
- 2026-10-30
AI Technical Summary
然而,现有量子图像分类方法通常需要将原始图像压缩为低维输入,容易造成病斑区域、纹理变化和边缘特征等细粒度信息丢失
[0042]1)本发明在量子编码前引入注意力增强机制,能够突出图像关键区域特征,减少背景和无关区域干扰,提高低维特征向量的构建质量;
Smart Images

Figure CN123016052A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image classification technology, and more particularly to the field of agricultural image classification technology, specifically a quantum convolutional integral classification method based on attention enhancement and supervised contrastive learning. Background Technology
[0002] Plant disease identification is an important research area in smart agriculture and precision agriculture. Traditional plant disease identification mainly relies on manual observation and expert experience, which suffers from low identification efficiency, high subjectivity, and difficulty in large-scale deployment. With the development of computer vision and deep learning technologies, image-based automatic plant disease identification methods have been extensively studied.
[0003] Convolutional neural networks can automatically extract color, texture, and shape features from images, achieving good results in plant disease identification tasks. However, deep convolutional models typically have a large number of parameters, placing high demands on computational resources and data scale. In lightweight agricultural intelligent diagnostic scenarios, achieving high recognition accuracy with limited computational resources remains a problem to be solved.
[0004] Quantum machine learning offers a novel approach to image classification. Quantum convolutional neural networks (CNNs) can classify low-dimensional input features using quantum circuits, and quantum evolutionary algorithms can further optimize the circuit structure of CNNs. However, existing quantum image classification methods typically require compressing the original image into a low-dimensional input, which can easily lead to the loss of fine-grained information such as lesion regions, texture variations, and edge features. If the low-dimensional features input to the quantum circuit lack discriminative power, even with structure search in the backend quantum circuit, stable classification performance is difficult to achieve.
[0005] Therefore, there is a need for an image classification method that can enhance key region features of an image before quantum encoding, optimize the low-dimensional feature space structure, and effectively combine with a quantum convolution classifier.
[0006] The information disclosed in the background section is only intended to enhance the understanding of the background of this disclosure, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention
[0007] The purpose of this invention is to provide a quantum convolution integral class method based on attention enhancement and supervised contrastive learning to solve the problems mentioned in the background art.
[0008] To achieve the above objectives, the present invention provides the following technical solution:
[0009] A quantum volume integral class method based on attention enhancement and supervised contrastive learning includes:
[0010] S1. Obtain the training image set with known type labels and, after image preprocessing, input it into the supervised contrastive learning module. Utilize supervised contrastive loss to optimize the feature space, so as to transform each training image in the training image set into a low-dimensional feature vector with high inter-class discriminative power.
[0011] The supervised contrastive learning module includes a feature extraction network, a global average pooling layer, and a non-linear projection head. The feature extraction network is used to enhance channel attention and spatial attention on the training images.
[0012] S2, after normalizing the low-dimensional feature vector, the quantum convolutional integral class model is pre-trained by combining the corresponding type labels. During the pre-training process, the quantum evolution algorithm and the simulated annealing algorithm are combined to solve the optimal quantum circuit of the quantum convolutional integral class model.
[0013] S3, combining the normalized low-dimensional feature vectors and corresponding type labels, trains the quantum convolutional class model based on the optimal quantum circuit;
[0014] S4. After extracting and normalizing the low-dimensional feature vector of the image to be tested, the vector is input into the trained quantum convolution integral class model to determine the type label of the image to be tested.
[0015] Furthermore, the image preprocessing includes size normalization and pixel normalization.
[0016] Furthermore, the feature extraction network includes a convolutional feature extraction layer and a convolutional block attention module, which transforms the preprocessed training images into attention-enhanced feature maps based on the feature extraction network;
[0017] Among them, the global average pooling layer is used to transform the attention-enhanced feature map into a one-dimensional feature vector;
[0018] The nonlinear projection head includes two fully connected layers with a ReLU activation function added between the layers, which are used to map a one-dimensional feature vector into the feature space.
[0019] Furthermore, the logic for transforming training images into low-dimensional feature vectors is as follows: Each training image, after preprocessing, is divided into several training batches. Each training batch is sequentially input into the supervised contrastive learning module for training. For any training image within the current training batch, it is paired with other training images in the same batch that have the same type label to form positive sample pairs, and paired with other training images in the same batch that have different type labels to form negative sample pairs. This maximizes the cosine similarity between the two training images in the positive sample pairs in the feature space and minimizes the cosine similarity between the two training images in the negative sample pairs. The cosine similarity between two training images in the feature space is used as the optimization direction to construct a supervised contrastive loss function. The Adam optimizer is used to update the network parameters of the supervised contrastive learning module through backpropagation to minimize the loss function until the predetermined maximum number of iterations is reached. Then, the nonlinear projection head in the supervised contrastive learning module is replaced with a fully connected layer. The preprocessed training images are then input into the supervised contrastive learning module again to obtain low-dimensional feature vectors that correspond one-to-one with each training image. In this way, each training image is transformed into a low-dimensional feature vector with high inter-class discriminative power.
[0020] Furthermore, the normalization method for low-dimensional feature vectors is determined by the encoding method. If amplitude encoding is used for low-dimensional feature vectors, L2 normalization is performed on the low-dimensional feature vectors with the constraint that the normalized magnitude of the low-dimensional feature vectors is equal to 1. If angle encoding is used for low-dimensional feature vectors, max-min normalization is performed on the low-dimensional feature vectors to normalize the element values of each dimension within the low-dimensional feature vectors to between 0 and π or 0 and 2π.
[0021] Furthermore, the quantum convolution integral class model includes the following structure:
[0022] A quantum coding layer is used to encode the normalized low-dimensional feature vectors in order to convert them into quantum states;
[0023] The quantum convolution pooling module is used to extract and filter features from quantum states to output the final compressed quantum state.
[0024] The quantum convolution pooling module consists of multiple quantum convolution pooling units stacked sequentially. The number of quantum convolution pooling units is determined based on the logarithmic reduction principle. For each quantum convolution pooling unit, it includes a quantum convolution layer and a quantum pooling layer that follows it.
[0025] The quantum measurement layer receives the final compressed quantum state and measures its expectation value using the Pauli operator, then maps it to a type label using the Softmax activation function.
[0026] Furthermore, the logic for solving the optimal quantum circuit is as follows:
[0027] 1) Assuming that the quantum gate arrangement schemes of all quantum convolutional layers and all quantum pooling layers are consistent, a quantum population probability matrix is constructed, and the quantum population probability matrix is updated based on the quantum evolution algorithm to solve for the general global optimal combination.
[0028] 2) Based on the general global optimal combination, an initial solution is constructed to characterize the quantum gate arrangement scheme of each quantum convolution layer and quantum pooling layer. The initial solution is iteratively optimized based on the simulated annealing algorithm to solve the refined global optimal combination. The quantum circuit corresponding to the refined global optimal combination is taken as the optimal quantum circuit.
[0029] Furthermore, the logic for solving the general globally optimal combination is as follows:
[0030] 1) Pair the normalized low-dimensional feature vectors with the corresponding type labels to form several data pairs. Summarize all data pairs to form a training database. Divide the training database into training set, test set and validation set according to a predetermined ratio.
[0031] 2) Assume that the quantum gate arrangement scheme of all quantum convolutional layers is consistent, and the quantum gate arrangement scheme of all quantum pooling layers is consistent, so as to construct a quantum population probability matrix. The rows in the quantum population probability matrix represent the quantum gate type and the columns represent the quantum gate position. The element values in the quantum population probability matrix are all initialized to the ratio of 1 to the number of quantum gate types.
[0032] 3) Perform multiple random samplings based on the quantum population probability matrix to generate multiple quantum gate combinations, and then construct quantum circuits that correspond one-to-one with each quantum gate combination. For each quantum circuit, use the training set to pre-train the quantum convolutional classification model based on the quantum circuit until the predetermined number of pre-training iterations is reached. Input the validation set into the quantum convolutional classification model based on the quantum circuit for validation, calculate the classification accuracy of the quantum convolutional classification model based on the quantum circuit on the validation set, and use this classification accuracy as the fitness value of the corresponding quantum gate combination.
[0033] 4) Select the quantum gate combination with the largest fitness value as a general local optimal combination, and determine the value of the element to be increased in the quantum population probability matrix based on this. After increasing the value of the element to be increased, the quantum population probability matrix is scaled and updated with the constraint that the cumulative value of the element values in the same column is equal to 1.
[0034] 5) Repeat step 3) until the predetermined maximum number of cycles is reached, determine the position of the maximum value of each column element in the quantum population probability matrix, and generate a general global optimal combination.
[0035] Furthermore, based on the general local optimal combination, the logic for determining the element value to be increased in the quantum population probability matrix is as follows: query the quantum gate type selected for each quantum gate position in the general local optimal combination, and use it as the preferred quantum gate type for the corresponding quantum gate position; lock the position representing the combination of each quantum gate position and the corresponding preferred quantum gate type from the quantum population probability matrix, and use it as the position to be increased; and use the element value at each position to be increased as the element value to be increased.
[0036] The logic for increasing the value of the element to be increased is as follows: a preset initial amplitude for probability increase and a termination amplitude for probability increase smaller than these are defined. Based on the current cycle number and the maximum number of cycle numbers, a baseline amplitude for probability increase in the current cycle is determined using a linear decay strategy. The difference between the mean and maximum fitness values of each quantum gate combination in the current cycle is analyzed to determine the excellence index of the general local optimal combination. This excellence index is used to correct the baseline amplitude for probability increase in the current cycle, resulting in a corrected amplitude for probability increase in the current cycle. The excellence index is positively correlated with the corrected amplitude for probability increase. The initial and termination amplitudes of probability increase are used as constraints to determine the maximum probability increase value in the current cycle, which is then added to the value of the element to be increased to complete the increase process.
[0037] Furthermore, the logic for solving the refined global optimal combination is as follows:
[0038] 1) Set the initial temperature, cooling rate and termination temperature, construct the initial solution based on the general global optimal combination, and use it as the current solution in the first round of annealing optimization. The initial solution includes the combination of quantum gate positions and quantum gate types in each quantum convolution layer, and the combination of quantum gate positions and quantum gate types in each quantum pooling layer.
[0039] 2) Iteratively execute annealing optimization until the temperature in the current annealing optimization round is lower than the termination temperature. In each annealing optimization round, the current solution in that annealing optimization round is randomly perturbed to generate a new solution, and the quantum circuit corresponding to the new solution is built. Using the method in step 3) when solving the general global optimal combination, the fitness value of the new solution is calculated. For each solution, the difference between 1 and the fitness value of the solution is calculated as the energy value of the solution. Combined with the temperature in that annealing optimization round, the energy values of the current solution and the new solution in that annealing optimization round are compared to determine whether to accept the new solution as the current solution for the next annealing optimization round.
[0040] 3) From each annealing optimization round, select the solution with the lowest energy value as the optimal solution, which is the refined global optimal combination, and the quantum circuit built based on the optimal solution is the optimal quantum circuit.
[0041] Compared with the prior art, the beneficial effects of the present invention include the following three points:
[0042] 1) This invention introduces an attention enhancement mechanism before quantum encoding, which can highlight the features of key regions of the image, reduce interference from background and irrelevant regions, and improve the construction quality of low-dimensional feature vectors;
[0043] 2) This invention introduces supervised contrastive learning to optimize the feature space, making samples of the same category more compact and samples of different categories more separated, thereby improving the separability of low-dimensional feature vectors under different types of labels;
[0044] 3) This invention combines quantum evolution algorithm and simulated annealing algorithm to optimize quantum circuits, thereby improving the classification performance of quantum convolutional classification model without increasing the size of quantum circuits or the number of qubits. It is suitable for image classification tasks under conditions of limited quantum resources. Attached Figure Description
[0045] Figure 1 This is a schematic flowchart of the overall method of the present invention;
[0046] Figure 2 The probability distribution diagram of each quantum gate position-type combination after initialization;
[0047] Figure 3 The probability distribution of each quantum gate position-type combination after one update;
[0048] Figure 4 The final updated probability distribution diagram for each quantum gate position-type combination;
[0049] Figure 5 This is a flowchart illustrating the logic of the image classification operation performed by the present invention. Detailed Implementation
[0050] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to specific embodiments.
[0051] It should be noted that, unless otherwise defined, the technical or scientific terms used in this invention should have the ordinary meaning understood by one of ordinary skill in the art to which this invention pertains. The terms "first," "second," and similar terms used in this invention do not indicate any order, quantity, or importance, but are merely used to distinguish different components. Terms such as "comprising" or "including" mean that the element or object preceding the word encompasses the elements or objects listed following the word and their equivalents, without excluding other elements or objects. Terms such as "connected" or "linked" are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. Terms such as "upper," "lower," "left," and "right" are used only to indicate relative positional relationships; when the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0052] Example:
[0053] Please see Figures 1-5 This invention provides a quantum convolution integral classification method based on attention enhancement and supervised contrastive learning, comprising:
[0054] S1. Obtain the training image set with known type labels and, after image preprocessing, input it into the supervised contrastive learning module. Utilize supervised contrastive loss to optimize the feature space, so as to transform each training image in the training image set into a low-dimensional feature vector with high inter-class discriminative power.
[0055] The supervised contrastive learning module includes a feature extraction network, a global average pooling layer, and a non-linear projection head. The feature extraction network is used to enhance channel attention and spatial attention on the training images.
[0056] As an implementation method, taking the binary classification task of tomato diseases as an example, images of tomato leaves in the early blight state are collected and their type label is defined as "early blight", which can be represented by the numerical label "0". Images of tomato leaves in the late blight state are collected and their type label is defined as "late blight", which can be represented by the numerical label "1". The tomato leaf images with the type labels "early blight" and "late blight" are summarized to form a training image set. Of course, the above classification method is not limited to the binary classification task of tomato diseases. It is also applicable to other crop disease classification tasks, crop growth status classification tasks, and other agricultural classification tasks. No specific classification application scenario is limited here.
[0057] Image preprocessing includes size normalization and pixel normalization;
[0058] As one implementation method, the specific operation of size normalization for any training image in the training image set is as follows: the image is scaled to adjust its size to a uniform fixed size, such as 224*224, 299*299, or 384*384, etc., without limitation, in order to eliminate the resolution difference between different training images and ensure that all training images can be input into the fixed-dimensional feature extraction network. In the process of scaling the training image to adjust its size to a fixed size, interpolation algorithms such as bilinear interpolation or bicubic interpolation are applied to interpolate and fill the image, thereby ensuring that as much texture detail as possible is preserved during the scaling of the training image, which helps to capture small lesions based on the attention mechanism in the subsequent process.
[0059] As one implementation method, the specific operation of pixel normalization for any training image in the training image set is as follows: For any pixel of the training image, the R channel pixel value, G channel pixel value, and B channel pixel value of the pixel are all subjected to maximum-minimum normalization processing to complete the pixel normalization processing of the training image. The pixel normalization setting can eliminate the influence of differences in image brightness, contrast, and color distribution on model training, and effectively accelerate the convergence speed of the loss function, preventing gradient explosion caused by excessively large pixel values in subsequent supervised contrastive learning. The logic of maximum-minimum normalization for any channel pixel value is as follows: 0 is taken as the minimum value and 255 is taken as the maximum value for maximum-minimum normalization processing. Specifically, the ratio of the channel pixel value to 255 is taken as the normalized value of the channel pixel value, thereby normalizing the pixel values of each channel to between 0 and 1.
[0060] The feature extraction network includes convolutional feature extraction layers and convolutional block attention modules. Based on the feature extraction network, the training images are transformed into attention-enhanced feature maps. The specific logic is as follows:
[0061] 1) Input the preprocessed training image into the convolutional feature extraction layer. Through multi-layer convolution operations, batch normalization and non-linear activation processing, the training image is transformed into a feature map containing spatial and channel information to be enhanced.
[0062] As one implementation method, the convolutional feature extraction layer consists of multiple convolutional layers employing residual or densely connected structures, typically 3-5 layers. In each convolutional layer, the kernel size is set to a standard 3x3, the stride is set to 1 to ensure pixel-by-pixel sliding, thereby maximizing the preservation of image detail information, and the padding is set to 1 to ensure that the input and output dimensions remain unchanged before and after convolution, thus preventing the loss of image edge information and facilitating the stacking of multiple convolutional layers. The convolutional kernel extracts shallow texture features from the training image by sliding along the image spatial dimension and performing cross-correlation operations, and forms a deep feature representation through multi-layer accumulation. Subsequently, batch normalization and non-linear activation processing are performed to finally generate the feature map to be enhanced. The specific operation of batch normalization is: performing batch normalization on the feature values obtained after convolution... Normalization and learnable linear reconstruction adjust the data distribution to a range that is easy to train. The specific operation of nonlinear activation is to use nonlinear activation functions such as ReLU or LeakyReLU to perform nonlinear transformation on the normalized data, thereby introducing nonlinear expressive power. The above convolutional feature extraction layer can specifically adopt the mature ResNet series convolutional neural network backbone architecture (such as ResNet-18, ResNet-34 or ResNet-50, etc.) or the DenseNet series convolutional neural network backbone architecture (such as DenseNet-121, DenseNet-169, etc.). The specific convolution operation, batch normalization and nonlinear activation are common knowledge in the art and will not be elaborated here.
[0063] 2) Input the feature map to be enhanced into the convolutional block attention module for feature enhancement to obtain the attention-enhanced feature map after channel attention enhancement and spatial attention enhancement. The convolutional block attention module is composed of channel attention module and spatial attention module stacked in series, and the channel attention module and spatial attention module are used to perform channel attention enhancement and spatial attention enhancement, respectively.
[0064] The logic for outputting the attention-enhanced feature map based on the convolutional block attention module is as follows: Channel attention is calculated on the feature map to be enhanced using the channel attention module to determine the channel weight vector, which consists of the channel weights of each feature channel within the feature map. The channel weight vector is then multiplied element-wise with the feature map to obtain the channel-enhanced feature map after channel attention enhancement. Then, spatial attention is calculated on the channel-enhanced feature map using the spatial attention module to determine the spatial weight vector, which consists of the spatial weights of each spatial location within the feature map. The spatial weight vector is then multiplied element-wise with the channel-enhanced feature map. This process performs spatial attention enhancement on the channel-enhanced feature map after channel attention enhancement, resulting in the attention-enhanced feature map.
[0065] The logic for performing channel attention calculation to determine the channel weight vector is as follows: The feature map to be enhanced is input into the channel attention module. The channel attention module performs global average pooling and global max pooling on the feature map to be enhanced through two parallel pooling branches to obtain the average pooling descriptor and max pooling descriptor of each feature channel in the feature map to be enhanced. The average pooling descriptor of each feature channel in the feature map to be enhanced is summarized to form an average pooling descriptor vector, and the max pooling descriptor of each feature channel in the feature map to be enhanced is summarized to form a max pooling descriptor vector. The average pooling descriptor vector and the max pooling descriptor vector are then input together into a multilayer perceptron (MLP) with shared weights. This MLP usually contains a hidden layer to achieve a dimensionality reduction followed by an increase, thereby reducing the number of parameters and improving generalization ability, so as to obtain the average pooling output vector and the max pooling output vector. The average pooling output vector and the max pooling output vector are added element by element and then input into the sigmoid activation function to generate the channel weight vector. This is common knowledge to those skilled in the art and will not be elaborated on here.
[0066] As one implementation, the two parallel pooling branches within the channel attention module are: 1) a global average pooling branch, which is used to perform global average pooling on the feature map to be enhanced; and 2) a global max pooling branch, which is used to perform global max pooling on the feature map to be enhanced.
[0067] Specifically, for any feature channel of the feature map to be enhanced, the average value of all pixels in the feature channel is calculated through the global average pooling branch to serve as the average pooling descriptor of the feature channel. This descriptor reflects the global background statistics and feature coverage of the feature channel. The maximum value of all pixels in the feature channel is calculated through the global max pooling branch to serve as the max pooling descriptor of the feature channel. This descriptor reflects the most distinctive feature saliency information of the feature channel. The average pooling descriptor and max pooling descriptor of the same feature channel complement each other to jointly constitute the complete semantic expression of the feature channel. This effectively characterizes the semantic association strength between each feature channel and the type label, providing a reliable basis for subsequent adaptive allocation of channel weights to output the channel-enhanced feature map.
[0068] The logic for performing spatial attention calculation to determine the spatial weight vector is as follows: The channel enhancement feature map is input into the spatial attention module. The spatial attention module performs average pooling and max pooling on the channel enhancement feature map in the channel dimension through two parallel pooling branches to obtain average pooling feature map and max pooling feature map. The average pooling feature map and max pooling feature map are concatenated and then passed through a convolutional layer to reduce the dimensionality to 1 channel. The result is then input into the sigmoid activation function to generate the spatial weight vector. The convolutional layer that performs the dimensionality reduction operation can use a large-scale convolutional kernel, such as a 7*7 size convolutional kernel. This is common knowledge to those skilled in the art and will not be elaborated on here.
[0069] It should be noted that the channel attention module performs cross-plane pooling when performing global average pooling and global max pooling on the feature map to be enhanced, compressing the spatial dimension. The resulting average pooling descriptor vector and max pooling descriptor vector have a dimension of C×1×1, where C is the number of feature channels. On the other hand, the spatial attention module performs cross-channel pooling when performing average pooling and max pooling on the channel enhanced feature map, compressing the channel dimension. The resulting average pooling feature map and max pooling feature map have a dimension of 1×H×W, where H and W are the height and width of the feature map, respectively. Therefore, when performing global average pooling and global max pooling on the feature map to be enhanced, the result is the average pooling descriptor vector and the max pooling descriptor vector. However, when performing average pooling and max pooling on the channel enhanced feature map, the result is the average pooling feature map and the max pooling feature map.
[0070] The global average pooling layer is used to transform the attention-enhanced feature map into a one-dimensional feature vector, thereby preserving important spatial features while initially reducing the computational load and preparing for subsequent supervised contrastive learning. The global average pooling layer is common knowledge to those skilled in the art and will not be elaborated here.
[0071] The nonlinear projection head includes two fully connected layers with a ReLU activation function added between the layers, which are used to map a one-dimensional feature vector into a feature space. In this feature space, the feature distribution of each training image can be better adjusted and reshaped. The nonlinear projection head is common knowledge to those skilled in the art and will not be described in detail here.
[0072] For any training image after image preprocessing, the processing logic in the supervised contrastive learning module is as follows: first, the training image is transformed into an attention-enhanced feature map through a feature extraction network; then, the attention-enhanced feature map is transformed into a one-dimensional feature vector through a global average pooling layer; and finally, the one-dimensional feature vector is mapped into the feature space through a non-linear projection head.
[0073] The logic for converting training images into low-dimensional feature vectors is as follows: Each preprocessed training image is divided into several training batches. Each training batch is sequentially input into the supervised contrastive learning module for training. For any training image in the current training batch, it is paired with other training images in the same batch that have the same type label to form positive sample pairs, and paired with other training images in the same batch that have different type labels to form negative sample pairs. This maximizes the cosine similarity between the two training images in a positive sample pair in the feature space and minimizes the cosine similarity between the two training images in a negative sample pair. The cosine similarity of images in the feature space is used as the optimization direction. A supervised contrastive loss function is constructed, and the Adam optimizer is used to update the network parameters of the supervised contrastive learning module through the backpropagation algorithm to minimize the loss function until the predetermined maximum number of iterations is reached. Then, the nonlinear projection head in the supervised contrastive learning module is replaced with a low-output-dimensional fully connected layer. Then, each training image after image preprocessing is input into the supervised contrastive learning module in sequence to obtain a low-dimensional feature vector corresponding to each training image. In this way, each training image is transformed into a low-dimensional feature vector with high inter-class discriminative power.
[0074] It should be noted that the optimization direction is to maximize the cosine similarity between the two training images in the feature space of the positive sample pair and minimize the cosine similarity between the two training images in the feature space of the negative sample pair. This is to make the samples of the same class more compact in the feature space and the samples of different classes more separated in the feature space, thereby ensuring the class separability of the low-dimensional feature vector, reducing the training difficulty of the subsequent quantum convolution integral classification model, accelerating its convergence rate and ensuring classification accuracy.
[0075] As one implementation method, when dividing the training batches, the batch size can be set to 32, 64, or 128, which can be set by the staff according to the actual situation. The network parameters specifically include the weights and biases of the fully connected layers in the nonlinear projection head, as well as the convolutional kernel parameters in the feature extraction network. The specific construction of the supervised contrastive loss function and the backpropagation optimization process are common knowledge in the art and will not be elaborated here. The maximum number of iterations can generally be set between 30 and 50, which can also be adjusted by the staff according to the actual situation. The output dimension of the fully connected layer used to replace the nonlinear projection head can be set to 8, 16, 32, or other fixed dimensions. For example, in this technical solution, a fully connected layer with an output dimension of 16 is used to replace the nonlinear projection head, so that after the supervised contrastive learning module receives the image, it is processed by the feature extraction network, the global average pooling layer, and the fully connected layer, and finally outputs a low-dimensional feature vector with a dimension of 16.
[0076] S2, after normalizing the low-dimensional feature vector, the quantum convolutional integral class model is pre-trained by combining the corresponding type labels. During the pre-training process, the quantum evolution algorithm and the simulated annealing algorithm are combined to solve the optimal quantum circuit of the quantum convolutional integral class model.
[0077] The specific method for normalizing low-dimensional feature vectors is determined by the encoding method. If amplitude encoding is used for low-dimensional feature vectors, L2 normalization is performed on the low-dimensional feature vectors with the constraint that the normalized modulus of the low-dimensional feature vectors is equal to 1. If angle encoding is used for low-dimensional feature vectors, maximum-minimum normalization is performed on the low-dimensional feature vectors to normalize the element values of each dimension in the low-dimensional feature vectors to between 0-π or 0-2π, which can be used as the rotation angle of the quantum rotating gate.
[0078] As an implementation method, in this technical solution, the low-dimensional feature vector has a low dimension and does not require further compression. Therefore, a more suitable angle encoding is adopted. Simultaneously, to ensure a good and unique mapping relationship between features and quantum states, avoid confusion during classification, and improve the convergence speed during model pre-training, a max-min normalization algorithm is used to normalize the element values of each dimension within the low-dimensional feature vector to 0-π. Specifically, the logic is as follows: Low-dimensional feature vectors obtained by transforming each training image in the training image set are summarized to construct a low-dimensional vector set. For the element value in any dimension of the low-dimensional feature vector, from... The maximum and minimum values of elements in the same dimension are obtained from the low-dimensional vector set. Based on this, the element values in that dimension of the low-dimensional feature vector are normalized to between 0 and 1, and then multiplied by π to normalize the element values in that dimension of the low-dimensional feature vector to between 0 and π. This completes the normalization process of the element values in each dimension of the low-dimensional feature vector, resulting in a normalized low-dimensional feature vector. The normalization process is used to scale the element values in each dimension of the low-dimensional feature vector to the same dimension, which is convenient for subsequent angular encoding. The maximum-minimum normalization process is common knowledge to those skilled in the art, and the specific mathematical expression will not be elaborated here.
[0079] The quantum convolution integral class model includes the following structure:
[0080] The quantum coding layer is used to encode the normalized low-dimensional feature vectors to convert them into quantum states. In this technical solution, the quantum coding layer adopts a quantum angle coding layer to encode the normalized low-dimensional feature vectors from an angle.
[0081] The quantum convolution pooling module is used to extract and filter features from quantum states to output the final compressed quantum state.
[0082] The quantum convolutional pooling module consists of multiple sequentially stacked quantum convolutional pooling units. The number of quantum convolutional pooling units is determined based on the logarithmic reduction principle, specifically the logarithm of the low-dimensional feature vector dimension to the base 2. For example, in this technical solution, the low-dimensional feature vector dimension is 16, so the quantum convolutional pooling module consists of four sequentially stacked quantum convolutional pooling units. The quantum convolutional pooling unit immediately following the quantum coding layer is designated as the first-level quantum convolutional pooling unit, and the quantum convolutional pooling unit immediately following the first-level quantum convolutional pooling unit is designated as the second-level quantum convolutional pooling unit, and so on. For each quantum convolutional pooling unit, it includes a quantum convolutional layer and a quantum pooling layer immediately following it, as detailed below:
[0083] A quantum convolutional layer is used to receive the output of a quantum coding layer or the previous quantum convolutional pooling unit. It increases the interaction between bits through transformation and extracts high-dimensional features. Specifically, if the quantum convolutional pooling unit in which a quantum convolutional layer is located is the first-level quantum convolutional pooling unit, it receives the output from the quantum coding layer. Otherwise, it receives the output of the previous-level quantum convolutional pooling unit, that is, it receives the output of the quantum pooling layer in the previous-level quantum convolutional pooling unit.
[0084] A quantum pooling layer is used to receive the output of a quantum convolutional layer in the same quantum convolutional pooling unit and perform dimensionality reduction and information compression on it to retain key feature information while reducing the number of qubits.
[0085] The quantum measurement layer is used to receive the final compressed quantum state, i.e., the output of the quantum pooling layer in the last-stage quantum convolution pooling unit, and to measure the expectation value of it with Pauli operators (such as Z operators), and then map it to a type label through the Softmax activation function;
[0086] The logic for solving the optimal quantum circuit is as follows:
[0087] 1) Assuming that the quantum gate arrangement schemes of all quantum convolutional layers and all quantum pooling layers are consistent, a quantum population probability matrix is constructed, and the quantum population probability matrix is updated based on the quantum evolution algorithm to solve for the general global optimal combination.
[0088] 2) Based on the general global optimal combination, an initial solution is constructed to characterize the quantum gate arrangement scheme of each quantum convolutional layer and quantum pooling layer. The initial solution is iteratively optimized based on the simulated annealing algorithm to solve the refined global optimal combination. The quantum circuit corresponding to the refined global optimal combination is taken as the optimal quantum circuit.
[0089] Furthermore, the logic for solving the general globally optimal combination is as follows:
[0090] 1) Pair the normalized low-dimensional feature vectors with the corresponding type labels to form several data pairs. Summarize all data pairs to form a training database. Divide the training database into training set, test set and validation set according to a predetermined ratio.
[0091] As one implementation method, a conventional model training method is adopted, and the training database is divided into training set, test set and validation set in a ratio of 70:15:15. This division of training set, test set and validation set provides a data foundation for subsequent model pre-training to solve the optimal quantum circuit.
[0092] 2) Assume that the quantum gate arrangement scheme of all quantum convolutional layers is consistent, and the quantum gate arrangement scheme of all quantum pooling layers is consistent, so as to construct a quantum population probability matrix. The rows in the quantum population probability matrix represent the quantum gate type and the columns represent the quantum gate position. The element values in the quantum population probability matrix are all initialized to the ratio of 1 to the number of quantum gate types.
[0093] It should be noted that the assumption that all quantum gate arrangements of all quantum convolutional layers and all quantum pooling layers are consistent is used to reduce the number of optimization parameters of the quantum evolution algorithm, reduce the optimization difficulty and computational cost, so as to quickly find a general global optimal combination suitable for all quantum convolutional layers and quantum pooling layers.
[0094] As an implementation method, based on a standard general configuration, five different types of quantum gates are set up: Identity(I), RX(θ), RY(θ), RZ(θ), and CNOT. Each quantum gate type is numbered, for example, Identity(I), RX(θ), RY(θ), RZ(θ), and CNOT are numbered 1, 2, 3, 4, and 5 respectively. The quantum gate type number is used as the row index of the quantum population probability matrix. Since convolutional blocks require sufficient degrees of freedom to capture features, multiple quantum gates need to be combined to form a representative entangled structure. Therefore, four quantum gate positions are set in the quantum convolutional layer to ensure the combination of multiple quantum gates. Of course, three or five quantum gate positions can also be set in the quantum convolutional layer; this is not a limitation. The main function of the pooling layer is information compression, which is generally achieved using two quantum gates. Feature extraction is complete. Therefore, based on Occam's razor, two quantum gate positions are set in the quantum pooling layer to ensure refinement, and each quantum gate position is numbered. For example, the four quantum gate positions in the quantum convolution layer are numbered 1, 2, 3, and 4, and the two quantum gate positions in the quantum pooling layer are numbered 5 and 6. The quantum gate position numbers are used as column indices of the quantum population probability matrix to construct a five-row, six-column quantum population probability matrix. Each element value in the quantum population probability matrix represents the probability of selecting the corresponding quantum gate type at the corresponding quantum gate position. For example, the element value in the second row and third column of the quantum population probability matrix represents the probability value of selecting the quantum gate type numbered 2 at the quantum gate position numbered 3. Since five different types of quantum gates are set above, the element values in the quantum population probability matrix are initialized to 0.2.
[0095] 3) Perform multiple random samplings based on the quantum population probability matrix to generate multiple quantum gate combinations, and then construct quantum circuits that correspond one-to-one with each quantum gate combination. For each quantum circuit, use the training set to pre-train the quantum convolutional classification model based on the quantum circuit until the predetermined number of pre-training iterations is reached. Input the validation set into the quantum convolutional classification model based on the quantum circuit for validation, calculate the classification accuracy of the quantum convolutional classification model based on the quantum circuit on the validation set, and use this classification accuracy as the fitness value of the corresponding quantum gate combination.
[0096] As an implementation method, the roulette wheel selection algorithm is used in the random sampling to generate quantum gate combinations. The roulette wheel selection algorithm is common knowledge to those skilled in the art and will not be described in detail here. Based on step 2) above, each quantum gate combination is a chromosome containing 6 gene positions. Each gene position corresponds to a quantum gate position, and the gene value in each gene position corresponds to a quantum gate type. Here, the number of the quantum gate position is used as the number of the gene position, and the number of the quantum gate type is used as the gene value in the gene position. For example, in a quantum gate combination, the gene value in the 4th gene position is 2, which means that in the quantum circuit corresponding to the quantum gate combination, a quantum gate of type RX(θ) is set at the quantum gate position numbered 4.
[0097] For each quantum gate combination, a corresponding type of quantum gate is set at each quantum gate position in the quantum convolution class model based on the quantum gate combination, so as to build a quantum circuit corresponding to the quantum gate combination in the quantum convolution class model.
[0098] The logic for pre-training the quantum convolutional integral class model based on each quantum circuit using the training set is as follows: The model is trained using low-dimensional feature vectors from the training set as input and corresponding type labels as output. During training, the cross-entropy loss function is used as the loss function, and the Adam optimizer or distributed stochastic gradient descent optimizer is employed. The model parameters, such as the rotation angle parameters in the quantum gate, are iteratively optimized based on the gradient backpropagation algorithm until a predetermined number of pre-training iterations is reached. The number of pre-training iterations is generally between 10 and 20, ensuring sufficient iterations while avoiding excessive computational resources in the pre-training step. The specific training process is common knowledge to those skilled in the art and will not be elaborated upon here.
[0099] It should be noted that the classification accuracy is the ratio of the number of correctly predicted type labels to the total number of predictions. This is a well-known technical indicator in the art. The higher the value, the better the corresponding quantum circuit, and thus the better the corresponding quantum gate combination. Therefore, the classification accuracy is used as the fitness value of the corresponding quantum gate combination.
[0100] 4) Select the quantum gate combination with the largest fitness value as a general local optimal combination, and determine the value of the element to be increased in the quantum population probability matrix based on this. After increasing the value of the element to be increased, the quantum population probability matrix is scaled and updated with the constraint that the cumulative value of the element values in the same column is equal to 1.
[0101] The logic for determining the element value to be increased in the quantum population probability matrix based on the general local optimal combination is as follows: query the quantum gate type selected for each quantum gate position in the general local optimal combination, and use it as the preferred quantum gate type for the corresponding quantum gate position. Lock the position representing the combination of each quantum gate position and the corresponding preferred quantum gate type from the quantum population probability matrix, and use it as the position to be increased. Use the element value at each position to be increased as the element value to be increased. For example, in the chromosome representing the general local optimal combination, the gene value in the 4th gene position is 2, then the element value in the second row and fourth column of the quantum population probability matrix is used as the element value to be increased.
[0102] As one implementation method, the logic for increasing the value of the element to be increased is as follows: a preset probability increase value is set, which can generally be set between 1% and 5% to ensure the continuity and controllability of the quantum population probability matrix update. The probability increase value is added to the value of the element to be increased to complete the increase of the value of the element to be increased. The increase of the value of the element to be increased is based on a fixed probability increase value, which has the advantages of simple operation and stable update.
[0103] As another implementation method, the logic for increasing the value of the element to be increased is as follows: a preset probability increase start value and a probability increase termination value smaller than these are defined. The current cycle number and the maximum number of cycle numbers are combined to determine the probability increase benchmark value for the current cycle number based on a linear decay strategy. The difference between the mean and maximum fitness values of each quantum gate combination in the current cycle number is analyzed to determine the excellence index of the general local optimal combination. Based on this excellence index, the probability increase benchmark value for the current cycle number is corrected to obtain the probability increase correction value for the current cycle number. The excellence index is positively correlated with the probability increase correction value. The probability increase start value and probability increase termination value are used as constraints to determine the probability increase magnitude for the current cycle number. This magnitude is then added to the value of the element to be increased to complete the increase process.
[0104] As one implementation method, the mathematical expression for increasing the reference amplitude of the probability is as follows:
[0105]
[0106] Moderate To increase the probability of the initial amplitude, To increase the probability of terminating the amplitude, The maximum number of cycles is predetermined. The index is the cycle number, and , Increase the base magnitude of the probability in the t-th cycle;
[0107] It should be noted that in the initial stage of the iterative optimization, the combinations of quantum gates in the same iteration are relatively scattered, and the combinations of quantum gates do not move toward the optimal solution. Therefore, a linear decay strategy is used to set a larger probability to increase the baseline amplitude, so that the quantum evolution algorithm can quickly widen the probability gap between different operators in the early stage of the search, quickly lock the potential region, and avoid wasting computational resources in useless space. As the iteration increases, the linear decay strategy is used to gradually decrease the probability and increase the baseline amplitude to prevent the optimal solution from being "skipped" due to the excessive step size, thereby ensuring that the quantum population probability matrix can smoothly converge to the global optimal solution.
[0108] As an implementation method, in order to ensure the continuity and controllability of the quantum population probability matrix update, the initial amplitude of the probability increase can generally be set to 5%, and the final amplitude of the probability increase can be set to 1%. Of course, the specific values can also be set by the staff according to the actual situation, which will not be elaborated here.
[0109] As one implementation method, the mathematical expression for the superiority index of the general local optimal combination is as follows:
[0110]
[0111] In the formula, Let be the maximum fitness value among all quantum gate combinations in the t-th cycle. Let be the mean fitness value of each quantum gate combination in the t-th cycle. The larger the difference between the two, the better the general-purpose local optimal combination is in the t-th cycle. Therefore, we use... The value quantifies the superiority of a general-purpose locally optimal combination; a larger value indicates a better general-purpose locally optimal combination in the t-th iteration. The preset excellence threshold is used to perform binary classification judgment on the excellence of general local optimal combinations, and it is a positive decimal less than 1;
[0112] It should be noted that when Greater than If the probability of a positive result is high, it indicates that the general local optimal combination is far superior to the average level. The base value should be increased with a higher probability, and the corresponding element value to be increased should be increased accordingly to accelerate the optimization. Conversely, if the probability of a positive result is low, it indicates that the general local optimal combination is only slightly superior to the average level. This suggests that the current search area may have encountered a bottleneck or noise interference. In this case, the base value should be increased with a lower probability or maintained to ensure cautious updates and prevent the quantum evolution algorithm from blindly following a mediocre solution.
[0113] As one implementation method, the excellence threshold is generally set between 0.4 and 0.6. For example, in this technical solution, it is considered that when the maximum fitness value is twice the mean, the excellence of the general local optimal combination is far greater than the average level. Therefore, the excellence threshold is set to 0.5. Of course, the specific value of the excellence threshold can also be adjusted by the staff according to the actual situation, and there is no restriction here.
[0114] As one implementation method, the mathematical expression for the magnitude of the probability increase is as follows:
[0115]
[0116] In the formula, This represents the probability increase correction magnitude in the t-th cycle. Used for The algorithm is modified to ensure that, in each iteration, while considering the decay of the magnitude as the algorithm progresses, it also takes into account the superiority of the general local optimal combination, thereby dynamically balancing the evolution rate and evolutionary precision of the quantum population probability matrix. This represents the probability increase magnitude in the t-th iteration. Here, the initial and final probability increase magnitudes are used as constraints to avoid wasting computational resources due to an excessively low optimization rate, while also avoiding the problem of missing the optimal solution due to an excessively fast optimization rate.
[0117] The logic for scaling and updating the quantum population probability matrix is as follows: for each element in the quantum population probability matrix, the cumulative value of the scaled element values in that column is equal to 1 as a constraint, and the values of each element in that column are scaled proportionally to ensure the rationality of the quantum population probability matrix.
[0118] 5) Repeat step 3) until the predetermined maximum number of cycles is reached, determine the position of the maximum value of each column element in the quantum population probability matrix, and generate a general global optimal combination;
[0119] As an implementation method, the maximum number of iterations can generally be set between 10 and 20 to ensure that the quantum population probability matrix is fully evolved while avoiding wasting too much computational resources in solving the general global optimal combination. The specific value can be set by the staff according to the actual situation.
[0120] The logic for generating a general global optimal combination is as follows: from the quantum population probability matrix updated in the last cycle, the position of the maximum value of each type of element is locked as the target position. The quantum gate position and quantum gate type combination represented by each target position are summarized to construct a general global optimal combination. For example, in the quantum population probability matrix updated in the last cycle, the element value in the third row of the second column is the largest. Then, in the chromosome representing the general global optimal combination, the gene value in the second gene position is set to 3.
[0121] The logic for solving the refined global optimal combination is as follows:
[0122] 1) Set the initial temperature, cooling rate, and termination temperature. Construct an initial solution based on the general global optimal combination and use it as the current solution in the first round of annealing optimization. The initial solution includes the combination of quantum gate positions and quantum gate types in each quantum convolutional layer and the combination of quantum gate positions and quantum gate types in each quantum pooling layer. In the initial solution, each quantum convolutional layer adopts the combination of quantum gate positions and quantum gate types in the general global optimal combination, and each quantum pooling layer adopts the combination of quantum gate positions and quantum gate types in the general global optimal combination.
[0123] As one implementation method, the initial solution consists of several chromosome segments that correspond one-to-one with the quantum convolutional layer / quantum pooling layer. For example, in this technical solution, a total of 4 quantum convolutional layers and 4 quantum pooling layers are set, so the initial solution is set to consist of 8 chromosome segments. After extracting the genes related to the quantum convolutional layer from the general global optimal combination, they are used as the chromosome segments corresponding to each quantum convolutional layer. For example, in this technical solution, the first four genes in the general global optimal combination are selected as the chromosome segments corresponding to each quantum convolutional layer in the initial solution. After extracting the genes related to the quantum pooling layer from the general global optimal combination, they are used as the chromosome segments corresponding to each quantum pooling layer. For example, in this technical solution, the last two genes in the general global optimal combination are selected as the chromosome segments corresponding to each quantum pooling layer in the initial solution.
[0124] As an implementation method, the general global optimal combination is a high-quality solution obtained by the quantum evolution algorithm. In subsequent steps, for any solution, the corresponding fitness value is subtracted from 1 to obtain the energy value of the solution. Therefore, the energy value is between 0 and 1 and the change is very small. Thus, the initial temperature should be set to a minimum value to avoid problems such as algorithm degradation or completely random search. For example, when the classification accuracy of the quantum convolutional classification model has reached more than 90% under the initial solution, the initial temperature can be set to 0.01. In the early stage of the simulated annealing algorithm, a new solution with a 1% decrease in classification accuracy is allowed with a 30% probability. Since the initial solution is a high-quality solution, there is no need to perform a violent global jump search, but a fine search is required. Therefore, the cooling rate should generally be set at a relatively high level between 0.95 and 0.99. Due to the small initial temperature and energy value, the termination temperature can generally be set at a relatively low level between 10^(-5) and 10^(-7). Of course, the above initial temperature, cooling rate and termination temperature can also be adjusted by the staff according to the actual situation, which will not be elaborated here.
[0125] 2) Iteratively execute annealing optimization until the temperature in the current annealing optimization round is lower than the termination temperature. In each annealing optimization round, the current solution in that annealing optimization round is randomly perturbed to generate a new solution, and the quantum circuit corresponding to the new solution is built. Using the method in step 3) when solving the general global optimal combination, the fitness value of the new solution is calculated. For each solution, the difference between 1 and the fitness value of the solution is calculated as the energy value of the solution. Combined with the temperature in that annealing optimization round, the energy values of the current solution and the new solution in that annealing optimization round are compared to determine whether to accept the new solution as the current solution for the next annealing optimization round.
[0126] The logic for randomly perturbing any current solution is as follows: multiple quantum gate positions are randomly selected from the current solution as perturbation positions, and the quantum gate type at the perturbation position in the current solution is changed to another quantum gate type. This completes the perturbation update of the current solution. Since the initial solution is a high-quality solution obtained based on the quantum evolution algorithm, it is not appropriate to excessively perturb the current solution. Therefore, when selecting perturbation positions from the current solution, it is generally sufficient to select 1-2 quantum gate positions to perform fine-grained search optimization based on the high-quality solution.
[0127] It should be noted that the above-mentioned determination of whether to accept the new solution as the current solution for the next annealing optimization round is a routine technical operation of the simulated annealing algorithm, which will not be elaborated here;
[0128] 3) From each annealing optimization round, select the solution with the lowest energy value as the optimal solution, which is the refined global optimal combination, and the quantum circuit built based on the optimal solution is the optimal quantum circuit.
[0129] S3, combining the normalized low-dimensional feature vectors and corresponding type labels, trains the quantum convolutional class model based on the optimal quantum circuit;
[0130] The training process for the quantum convolutional integral classification model based on the optimal quantum circuit is as follows: The model is trained using low-dimensional feature vectors from the training set as input and corresponding type labels as output. During training, the cross-entropy loss function is used as the loss function, and the Adam optimizer or distributed stochastic gradient descent optimizer is employed. The model parameters, such as the rotation angle parameters in the quantum gate, are iteratively optimized based on the gradient backpropagation algorithm until the predetermined maximum number of training iterations is reached, typically between 30 and 50, to ensure sufficient training of the model. The test set is then input into the model for testing. The classification accuracy of the model on the test set is calculated, and it is determined whether the accuracy exceeds a threshold. If it does, training is considered complete; otherwise, the process returns to step S2 to re-solve for the optimal quantum circuit.
[0131] S4. After extracting and normalizing the low-dimensional feature vector of the image to be tested, the vector is input into the trained quantum convolution integral class model to determine the type label of the image to be tested.
[0132] It should be noted that when normalizing the low-dimensional feature vectors of the test image, the scheme in step S2 is followed. For example, the angle encoding method is used in this technical solution. When normalizing the low-dimensional feature vectors of the test image, the maximum and minimum values of each dimension element in the low-dimensional vector set are used to ensure that the normalization logic of each low-dimensional feature vector is consistent.
[0133] The above formulas are all dimensionless calculations. The formulas are derived from software simulations based on a large amount of collected data to obtain the most recent real-world results. The preset parameters in the formulas are set by those skilled in the art according to the actual situation.
[0134] The above embodiments can be implemented, in whole or in part, by software, hardware, firmware, or any other combination thereof. When implemented in software, the above embodiments can be implemented, in whole or in part, as a computer program product. Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution.
[0135] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment, depending on actual needs.
[0136] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
Claims
1. A quantum volume integral classification method based on attention enhancement and supervised contrastive learning, characterized in that, include: S1. Obtain the training image set with known type labels and, after image preprocessing, input it into the supervised contrastive learning module. Utilize supervised contrastive loss to optimize the feature space, so as to transform each training image in the training image set into a low-dimensional feature vector with high inter-class discriminative power. The supervised contrastive learning module includes a feature extraction network, a global average pooling layer, and a non-linear projection head. The feature extraction network is used to enhance channel attention and spatial attention on the training images. S2, after normalizing the low-dimensional feature vector, the quantum convolutional integral class model is pre-trained by combining the corresponding type labels. During the pre-training process, the quantum evolution algorithm and the simulated annealing algorithm are combined to solve the optimal quantum circuit of the quantum convolutional integral class model. S3, combining the normalized low-dimensional feature vectors and corresponding type labels, trains the quantum convolutional class model based on the optimal quantum circuit; S4. After extracting and normalizing the low-dimensional feature vector of the image to be tested, the vector is input into the trained quantum convolution integral class model to determine the type label of the image to be tested.
2. The quantum convolutional integral classification method based on attention enhancement and supervised contrastive learning according to claim 1, characterized in that, The image preprocessing includes size normalization and pixel normalization.
3. The quantum convolutional integral classification method based on attention enhancement and supervised contrastive learning according to claim 1, characterized in that, The feature extraction network includes a convolutional feature extraction layer and a convolutional block attention module. Based on the feature extraction network, the training images after image preprocessing are transformed into attention-enhanced feature maps. Among them, the global average pooling layer is used to transform the attention-enhanced feature map into a one-dimensional feature vector; The nonlinear projection head includes two fully connected layers with a ReLU activation function added between the layers, which are used to map a one-dimensional feature vector into the feature space.
4. The quantum convolutional integral classification method based on attention enhancement and supervised contrastive learning according to claim 3, characterized in that, The logic for transforming training images into low-dimensional feature vectors is as follows: Each training image, after preprocessing, is divided into several training batches. Each training batch is sequentially input into the supervised contrastive learning module for training. For any training image in the current training batch, other training images in the current batch with the same type label are paired with it to form positive sample pairs, and other training images in the current batch with different type labels are paired with it to form negative sample pairs. The optimization direction is to maximize the cosine similarity between the two training images in the feature space of the positive sample pairs and minimize the cosine similarity between the two training images in the feature space of the negative sample pairs. A supervised contrastive loss function is constructed, and the Adam optimizer is used to update the network parameters of the supervised contrastive learning module through backpropagation to minimize the loss function until the predetermined maximum number of iterations is reached. Then, the nonlinear projection head in the supervised contrastive learning module is replaced with a fully connected layer. The preprocessed training images are then sequentially input into the supervised contrastive learning module again to obtain low-dimensional feature vectors corresponding to each training image. This transforms each training image into a low-dimensional feature vector with high inter-class discriminative power.
5. The quantum convolutional integral classification method based on attention enhancement and supervised contrastive learning according to claim 1, characterized in that, The normalization method for low-dimensional feature vectors is determined by the encoding method. If amplitude encoding is used for low-dimensional feature vectors, L2 normalization is performed on the low-dimensional feature vectors with the constraint that the normalized magnitude of the low-dimensional feature vectors is equal to 1. If angle encoding is used for low-dimensional feature vectors, max-min normalization is performed on the low-dimensional feature vectors to normalize the element values of each dimension within the low-dimensional feature vectors to between 0 and π or 0 and 2π.
6. The quantum convolutional integral classification method based on attention enhancement and supervised contrastive learning according to claim 1, characterized in that, The quantum volume integral class model includes the following structure: A quantum coding layer is used to encode normalized low-dimensional feature vectors in order to transform them into quantum states; The quantum convolution pooling module is used to extract and filter features from quantum states to output the final compressed quantum state. The quantum convolution pooling module consists of multiple quantum convolution pooling units stacked sequentially. The number of quantum convolution pooling units is determined based on the logarithmic reduction principle. For each quantum convolution pooling unit, it includes a quantum convolution layer and a quantum pooling layer that follows it. The quantum measurement layer receives the final compressed quantum state and measures its expectation value using the Pauli operator, then maps it to a type label using the Softmax activation function.
7. The quantum convolutional integral classification method based on attention enhancement and supervised contrastive learning according to claim 6, characterized in that, The logic for finding the optimal quantum circuit is as follows: 1) Assuming that the quantum gate arrangement schemes of all quantum convolutional layers and all quantum pooling layers are consistent, a quantum population probability matrix is constructed, and the quantum population probability matrix is updated based on the quantum evolution algorithm to solve for the general global optimal combination. 2) Based on the general global optimal combination, an initial solution is constructed to characterize the quantum gate arrangement scheme of each quantum convolution layer and quantum pooling layer. The initial solution is iteratively optimized based on the simulated annealing algorithm to solve the refined global optimal combination. The quantum circuit corresponding to the refined global optimal combination is taken as the optimal quantum circuit.
8. The quantum convolutional integral classification method based on attention enhancement and supervised contrastive learning according to claim 7, characterized in that, The logic for solving the general globally optimal combination is as follows: 1) Pair the normalized low-dimensional feature vectors with the corresponding type labels to form several data pairs. Summarize all data pairs to form a training database. Divide the training database into training set, test set and validation set according to a predetermined ratio. 2) Assume that the quantum gate arrangement scheme of all quantum convolutional layers is consistent, and the quantum gate arrangement scheme of all quantum pooling layers is consistent, so as to construct a quantum population probability matrix. The rows in the quantum population probability matrix represent the quantum gate type and the columns represent the quantum gate position. The element values in the quantum population probability matrix are all initialized to the ratio of 1 to the number of quantum gate types. 3) Perform multiple random samplings based on the quantum population probability matrix to generate multiple quantum gate combinations, and then construct quantum circuits that correspond one-to-one with each quantum gate combination. For each quantum circuit, use the training set to pre-train the quantum convolutional classification model based on the quantum circuit until the predetermined number of pre-training iterations is reached. Input the validation set into the quantum convolutional classification model based on the quantum circuit for validation, calculate the classification accuracy of the quantum convolutional classification model based on the quantum circuit on the validation set, and use this classification accuracy as the fitness value of the corresponding quantum gate combination. 4) Select the quantum gate combination with the largest fitness value as a general local optimal combination, and determine the value of the element to be increased in the quantum population probability matrix based on this. After increasing the value of the element to be increased, the quantum population probability matrix is scaled and updated with the constraint that the cumulative value of the element values in the same column is equal to 1. 5) Repeat step 3) until the predetermined maximum number of cycles is reached, determine the position of the maximum value of each column element in the quantum population probability matrix, and generate a general global optimal combination.
9. The quantum convolutional integral classification method based on attention enhancement and supervised contrastive learning according to claim 8, characterized in that, Based on the general local optimal combination, the logic for determining the element value to be increased in the quantum population probability matrix is as follows: query the quantum gate type selected for each quantum gate position in the general local optimal combination, and use it as the preferred quantum gate type for the corresponding quantum gate position; lock the position representing the combination of each quantum gate position and the corresponding preferred quantum gate type from the quantum population probability matrix, and use it as the position to be increased; and use the element value at each position to be increased as the element value to be increased. The logic for increasing the value of the element to be increased is as follows: a preset initial amplitude for probability increase and a termination amplitude for probability increase smaller than these are defined. Based on the current cycle number and the maximum number of cycle numbers, a baseline amplitude for probability increase in the current cycle is determined using a linear decay strategy. The difference between the mean and maximum fitness values of each quantum gate combination in the current cycle is analyzed to determine the excellence index of the general local optimal combination. This excellence index is used to correct the baseline amplitude for probability increase in the current cycle, resulting in a corrected amplitude for probability increase in the current cycle. The excellence index is positively correlated with the corrected amplitude for probability increase. The initial and termination amplitudes of probability increase are used as constraints to determine the maximum probability increase value in the current cycle, which is then added to the value of the element to be increased to complete the increase process.
10. The quantum convolutional integral classification method based on attention enhancement and supervised contrastive learning according to claim 8, characterized in that, The logic for solving the refined global optimal combination is as follows: 1) Set the initial temperature, cooling rate and termination temperature, construct the initial solution based on the general global optimal combination, and use it as the current solution in the first round of annealing optimization. The initial solution includes the combination of quantum gate positions and quantum gate types in each quantum convolution layer, and the combination of quantum gate positions and quantum gate types in each quantum pooling layer. 2) Iteratively execute annealing optimization until the temperature in the current annealing optimization round is lower than the termination temperature. In each annealing optimization round, the current solution in that annealing optimization round is randomly perturbed to generate a new solution, and the quantum circuit corresponding to the new solution is built. Using the method in step 3) when solving the general global optimal combination, the fitness value of the new solution is calculated. For each solution, the difference between 1 and the fitness value of the solution is calculated as the energy value of the solution. Combined with the temperature in that annealing optimization round, the energy values of the current solution and the new solution in that annealing optimization round are compared to determine whether to accept the new solution as the current solution for the next annealing optimization round. 3) From each annealing optimization round, select the solution with the lowest energy value as the optimal solution, which is the refined global optimal combination, and the quantum circuit built based on the optimal solution is the optimal quantum circuit.
