Quantum neural network optimization method based on dual-channel coding and frequency measurement
By using dual-channel feature extraction and frequency measurement technology, combined with amplitude coding and angle coding, a simple quantum circuit structure is constructed, which solves the complexity and resource consumption problems of quantum neural networks in small-sample text classification tasks, and achieves efficient text classification and robustness improvement.
Patent Information
- Application Number
- CN202510729581.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-03
- Publication Date
- 2025-09-16
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing quantum neural networks have problems in small-sample text classification tasks, such as complex quantum circuits, large number of parameters, insufficient feature compression, poor robustness, and insufficient adaptability of NISQ devices.
Using dual-channel feature extraction, quantum state amplitude coding, frequency measurement and other technologies, sparse vectors are generated through one-hot coding and TF-IDF coding, and feature compression is performed by combining amplitude coding and angle coding. The quantum state is converted into a classical vector through multiple measurement frequency estimation, constructing a simple quantum circuit structure to adapt to NISQ devices.
It significantly reduces the complexity of quantum circuits and the number of parameters, improves the classification accuracy and robustness in small sample tasks, adapts to the practical application of NISQ devices, reduces computing resource consumption, and improves the model's semantic information fusion capability and classification performance.
Smart Images

Figure CN120654842A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of quantum computing technology, and in particular to a quantum neural network optimization method based on dual-channel coding and frequency measurement. Background Art
[0002] With the rapid development of quantum computing technology, the application of quantum neural networks (QNNs) in natural language processing (NLP) has attracted widespread attention. Existing research mainly explores the use of quantum superposition and entanglement properties to improve the expressiveness of models and small-sample learning performance in text classification tasks.
[0003] The Quantum Self-Attention Neural Network (QSANN), based on high-dimensional quantum state encoding and Gaussian projection quantum self-attention, implements quantum operations on queries, keys, and values through parameterized quantum circuits, effectively mining inter-word correlations and achieving good classification performance on MC and RP datasets. However, this approach requires the construction of complex encoding and quantum circuits, resulting in high quantum circuit depth and a large number of parameters. This makes it prone to overfitting in small sample tasks and poses limited stability when running on actual NISQ devices.
[0004] The Multi-Scale Feature Fusion Quantum Depthwise Separable Convolutional Neural Network (MSFF-QDConv) extracts word-level and sentence-level features through a quantum deep convolutional architecture and amplitude-angle dual encoding, effectively improving the model's ability to capture text features and achieving a test accuracy of 96.77% on the RP dataset. However, the Ansatz architecture suffers from a relatively deep structure, high overall training resource consumption, and inability to achieve fully accurate classification with small sample sizes.
[0005] A quantum loop architecture based on parameterized quantum circuits maps text into quantum states through angle encoding and uses loop structures to model contextual dependencies, making it suitable for small-scale text datasets. Although this model achieves performance similar to a range of classical neural network models, it is still limited by the number of quantum bits and circuit complexity, limiting its overall scalability.
[0006] For low-resource languages, a batch upload quantum recurrent neural network (BUQRNN) and a position-normalized batch upload quantum recurrent neural network (PN-BUQRNN) were proposed. Combining a classical pre-trained language model with quantum recurrent units, they effectively improved the accuracy of text classification for low-resource languages. However, this method requires batch processing of a large number of quantum states, resulting in a high number of measurements and training complexity.
[0007] Furthermore, the hybrid classical-quantum transfer learning (CQTL) method, which extracts classical features and then feeds them into a quantum decision layer, alleviates the problem of quantum resource consumption and improves small-sample classification performance. However, this approach relies on large-scale classical feature extraction, limiting the scalability of pure quantum methods.
[0008] In summary, existing quantum text classification methods have made initial progress in dataset feature extraction, model classification performance, and feature dimension compression, but they generally have the following shortcomings: (1) The depth of quantum circuits is large, resulting in serious noise accumulation; (2) The number of parameters is large, the training resource overhead is high, and it is easy to overfit; (3) The quantum measurement mechanism is single, and there is a lack of efficient and stable compression feature generation methods; (4) The multi-channel semantic fusion capability is weak, which limits the comprehensive expression of the semantic space; (5) The deployment adaptability of noisy intermediate-scale quantum (NISQ) devices is insufficient, and the engineering feasibility needs to be improved.
[0009] The main reason for these issues is that existing technologies generally pursue maximizing feature extraction capabilities, improving model expressiveness through superimposed quantum state encoding and deep parameterized circuits. However, this also introduces excessive training parameters and complex quantum gate operations, making it difficult to efficiently execute the models on practical quantum devices with limited resources. Furthermore, when it comes to small-sample text classification tasks, existing quantum models lack targeted data dimensionality reduction and feature compression mechanisms, resulting in redundant input information and amplified feature extraction noise, ultimately affecting the model's generalization and classification accuracy.
[0010] Therefore, there is an urgent need for a new QNNs text classification solution with a simple structure, efficient feature compression, excellent classification performance, and the ability to adapt to small sample tasks and the actual hardware conditions of NISQ devices, so as to further promote the development of the field of quantum natural language processing (QNLP).
[0011] Existing QNNs-based text classification methods have the following shortcomings:
[0012] (1) Quantum circuits are complex and have a large number of parameters
[0013] Some models, such as QSANN, require complex data encoding and deep parameterized quantum circuits when implementing high-dimensional feature extraction, resulting in a large number of model parameters and excessively deep quantum circuits, which is not conducive to actual deployment on NISQ devices.
[0014] (2) The overall structure is heavy and the performance of small samples is insufficient
[0015] Although some methods such as MSFF-QDConv have improved in accuracy, their overall structure is complex, they consume a lot of quantum circuit resources, and they still have the problem of insufficient classification accuracy on small sample data sets.
[0016] (3) Insufficient feature compression and poor robustness
[0017] In the process of feature extraction and quantum state encoding, existing methods process input information redundantly, fail to effectively compress and retain key information, and are easily affected by noise, resulting in limited model robustness and generalization ability. Summary of the Invention
[0018] The present invention aims to provide a quantum neural network optimization method based on dual-channel coding and frequency measurement, aiming to address the technical problems existing in existing quantum neural network models in small-sample text classification tasks. By adopting dual-channel feature extraction, quantum state amplitude coding, frequency measurement and other technologies, the present invention significantly reduces the complexity and number of parameters of quantum circuits, solving the problems of high training resource consumption, severe quantum noise interference, and overfitting in practical applications of quantum models. Through quantum amplitude coding and a simplified quantum circuit structure, the present invention reduces the number of required quantum bits and training parameters, making it particularly suitable for practical applications in current medium-scale quantum NISQ devices with low noise, and reducing computing resource consumption. In addition, by optimizing quantum feature extraction and quantum dimensionality reduction processing, the classification accuracy and robustness in small-sample tasks are improved, avoiding the overfitting problem caused by data scarcity in traditional methods. The quantum measurement frequency estimation method introduced in the present invention converts quantum states into classical vectors by measuring frequencies multiple times, avoiding complex observation operator design and improving the interpretability and stability of model output. Finally, the feature fusion method combining dual channels (one-hot encoding and TF-IDF encoding) with quantum compression and angle encoding enhances the fusion ability of semantic information and improves classification performance. In summary, this invention provides an innovative solution for quantum natural language processing (QNLP) tasks by combining the efficient feature compression and dimensionality reduction technology of quantum computing with classical feature extraction methods. It is particularly suitable for application scenarios with small samples and limited computing resources, and has good engineering feasibility and broad promotion prospects.
[0019] Based on VQC, this paper proposes a QNNs model that combines dual-channel feature extraction, amplitude encoding, parameterized circuit training, a custom quantum measurement mechanism, and a secondary classifier. This method is suitable for NLP text classification, particularly for the compression and representation of high-dimensional sparse semantic data. This method boasts strong semantic modeling capabilities, high compression efficiency, excellent classification accuracy, good interpretability, and deployability on NISQ devices.
[0020] In order to achieve the above-mentioned invention object, the present invention adopts the following technical solutions: a quantum neural network optimization method based on dual-channel coding and frequency measurement, Figure 1 The basic process of this model is demonstrated. By introducing technologies such as dual-channel feature extraction, quantum state compression, and multiple measurement frequency estimation, this model can achieve efficient and accurate text classification under small sample and limited resource conditions. The following are the specific steps for model optimization:
[0021] Step 1: Use dual-channel feature extraction to vectorize text encoding:
[0022] One-hot encoding: Each word is converted into a high-dimensional sparse vector through one-hot encoding. The one-hot vectors of all words appearing in a sentence are accumulated to generate a sentence-level sparse vector, avoiding word frequency bias and ensuring semantic integrity and interpretability.
[0023] TF-IDF encoding: A term frequency-inverse document frequency algorithm is used to generate a vector for each word, reflecting the semantic strength and importance of the term. These vectors constitute the importance weight of each word in the sentence, further extracting the semantic information of the sentence.
[0024] Step 2: Prepare and compress quantum states using amplitude coding:
[0025] Perform L2 norm normalization on the one-hot and TF-IDF encoded sparse vectors obtained from Step 1 so that the sum of the squares of each vector is 1.
[0026] Amplitude coding maps each normalized vector onto a qubit, converting classical information into a quantum state. By mapping classical data onto the amplitude of the qubit, amplitude coding achieves feature compression, compressing high-dimensional sparse vectors into low-dimensional quantum states and reducing computational overhead.
[0027] Step 3: Ansatz construction and quantum circuit training:
[0028] The VQC structure is used to input the amplitude-encoded quantum state into the quantum circuit.
[0029] In a quantum circuit, a single-bit rotation gate is first applied to adjust the state of the qubit, then entanglement between qubits is introduced through a local CNOT gate, and then the global information interaction between qubits is further enhanced through a fully connected CNOT gate.
[0030] The Adam optimizer is used to optimize the parameters of the quantum circuit. The objective function uses binary cross entropy to minimize the classification error rate. Each channel (one-hot encoding and TF-IDF encoding channel) is trained independently, and the final optimal parameters and circuit structure are saved.
[0031] Step 4: Quantum measurement and frequency estimation:
[0032] By performing multiple measurements on each qubit, recording the frequencies of the "0" and "1" states, and mapping these frequencies to classical values, the qubit's state is converted into a classical vector through this frequency estimation method.
[0033] This method does not require the design of complex observation operators, and the results are interpretable and numerically stable. The generated classical vectors are used for subsequent tasks.
[0034] Step 5: Feature fusion and classifier training:
[0035] The two compressed classical vectors from the one-hot and TF-IDF channels are concatenated to form a new fused feature vector. This concatenated feature vector is then angle-encoded, mapping each vector element to the rotation angle of a revolving gate. This encoding enhances the adaptability of quantum circuits to the fused semantic space.
[0036] The fused feature vector is input into the quantum circuit to form a secondary quantum classifier and trained again.
[0037] Step 6: Result prediction and model optimization:
[0038] After training is completed, the test data is classified by the quantum classifier and the classification results of the test samples are output. The output 0 or 1 indicates the category to which the sentence belongs.
[0039] By using a small number of training parameters (e.g., only 30 trainable parameters on the MC dataset and only 42 trainable parameters on the RP dataset), this method can achieve 100% classification accuracy, significantly improving the classification performance in small sample tasks.
[0040] from Figure 2 It can be seen that the Ansatz structure proposed in the present invention consists of three sections: first, a single-bit R x The rotating gate layer assigns learnable parameters to each qubit; secondly, a local entanglement structure is applied, namely a ring CNOT gate, so that all adjacent qubits form a closed entangled network; then enter the second stage, apply R y The gate and execute the CNOT loop again; the third stage is R z Rotation gates and fully connected CNOT gates ensure global information exchange between qubits. This structure combines local and global entanglement mechanisms, enhancing the model's expressiveness while effectively controlling the number of parameters, making it suitable for efficient training on NISQ devices.
[0041] During the quantum circuit training process, the present invention uses the Adam optimizer to iteratively update the parameter gates in the quantum circuit. The objective function is the binary cross entropy, which is expressed as formula (1):
[0042]
[0043] If it is the average loss of a batch of samples, the function can also be rewritten as formula (2):
[0044]
[0045] Where y is the true label y∈{0,1}, is the predicted probability N is the sample size.
[0046] This function is suitable for 0 / 1 classification problems. Each channel is trained independently and the final optimal parameters and circuit structure are saved to ensure the stability and consistency of the compressed representation.
[0047] After the training is completed, in order to convert the quantum state into a classical vector that can be processed by downstream tasks, the present invention introduces a custom quantum measurement method based on multiple measurement frequency estimation, as shown in formula (3):
[0048]
[0049] This method is used for the i-th quantum bit q i Perform M measurements and record the kth measurement result r i (k) ∈{0, 1}, the frequency f of state “1” is obtained statistically i (1) , and mapped to the classical value m of the corresponding dimension of the quantum bit i =-f i (1) ;Frequency f of state "0" i (0) Then it is mapped to the classic value m of the corresponding dimension i =f i (0) , thus forming an n-dimensional real vector. This measurement method does not require the design of complex observation operators and has the advantages of simple implementation, interpretable results, and numerical stability. The generated vector can be reused as input vectors for subsequent training or other tasks, forming an effective "quantum state → classical vector" conversion mechanism.
[0050] Subsequently, the present invention combines the compressed vectors output by the two channels to form a final expression vector V = [V onehot ||V tfidf ] and re-embed it into the quantum circuit using an angle encoding mechanism to form a secondary quantum classifier. This classifier structure remains consistent with the aforementioned Ansatz. It is retrained to adapt to the fused semantic space and performs the final prediction output for the test sample. The classifier output is 0 or 1, indicating the category to which the sentence belongs.
[0051] The present invention was experimentally evaluated on two public datasets: the MC task is a sentence semantic binary classification dataset, which contains multiple short sentences automatically generated by grammatical rules; the RP task is derived from the RELPRON semantic test set, which requires judging the subject-object status of relative clause structures. The two datasets represent two typical tasks: small vocabulary + clear classification, and complex structure + testing transfer ability. In both types of tasks, the method of the present invention achieved a classification accuracy of 100%, significantly outperforming the currently published QNNs models (such as QSANN and MSFF-QDConv), verifying the effectiveness of its model structure in terms of information compression ability, semantic expression, generalization ability, etc.
[0052] All quantum computing modules (amplitude encoding, Ansatz construction, and quantum measurement) employed in this paper can be implemented on mainstream platforms such as Qiskit and Pennylane, ensuring excellent engineering feasibility. The model runs stably on both current mainstream simulators and actual NISQ devices, supporting application scenarios such as training parameter preservation, compressed vector reuse, and multi-task migration.
[0053] Compared with the prior art, the present invention has the following beneficial effects:
[0054] 1. The present invention provides a text classification method that combines quantum dimensionality reduction technology with a classical feature fusion strategy. It uses a concise and efficient structural design to achieve effective representation and accurate classification of text data. By compressing the feature dimensions of the input data and integrating multiple classical information representation methods, the accuracy and robustness of the model in classification tasks are greatly improved while maintaining semantic integrity. This method is particularly suitable for text processing needs in resource-limited and small sample scenarios, and has good feasibility and promotion value.
[0055] 2. The present invention adopts a lightweight VQC structure, combines the classic feature fusion method of One-hot encoding and TF-IDF encoding, and introduces the data compression and embedding mechanism of amplitude encoding and angle encoding to achieve efficient extraction and dimensionality reduction of text features using quantum bits. Compared with the existing technology, the present invention significantly reduces the amount of parameter training, reduces quantum resource consumption, and improves the classification accuracy and robustness of the model under small sample data sets while maintaining a simple model structure, a small number of quantum bits, and a low circuit depth. Specifically, on the MC and RP data sets, 100% classification accuracy was achieved using only 30 and 42 training parameters, respectively, effectively solving the problems of large parameter scale, high risk of overfitting, insufficient small sample performance, and strong noise sensitivity of quantum devices in existing models. It has good practical application potential and promotion value.
[0056] (1) The model structure is simple and the quantum resource consumption is greatly reduced
[0057] Compared with existing methods such as the QSANN model, which requires a larger number of quantum bits and complex encoding, the present invention only uses single-digit quantum bits to complete feature processing and classification, significantly reducing dependence on quantum resources and being more suitable for the application requirements of current NISQ devices.
[0058] (2) Very few training parameters and low training overhead
[0059] The present invention only requires 30 trainable parameters on the MC dataset and only 42 trainable parameters on the RP dataset to complete the classification task, which is much lower than existing methods such as QSANN (which requires 25 to 109 parameters) and the MSFF-QDConv model (which requires a higher parameter scale). It effectively reduces the training computational overhead and improves training efficiency.
[0060] (3) Small sample classification accuracy is greatly improved
[0061] On two public small datasets, MC and RP, the present invention can achieve 100% classification accuracy using only very few training parameters, while the existing technology can only achieve a maximum accuracy of 96.77% on the RP dataset, showing significant performance advantages in small sample learning scenarios.
[0062] (4) Sufficient feature compression, strong robustness and stability
[0063] By introducing amplitude coding for feature dimensionality reduction and compression, the present invention effectively reduces the noise interference caused by high-dimensional features while maintaining the original semantics of the text. The model exhibits greater robustness and stability in noisy environments, reducing the performance degradation problem caused by quantum noise.
[0064] (5) Wide range of applications and practical promotion potential
[0065] 3. The present invention has a simple structure, controllable parameters, and excellent classification performance. It is particularly suitable for application scenarios with limited quantum device resources and limited sample size. It has a good practical deployment mechanism and industrial application prospects.
[0066] 1) Constructing sentence-level one-hot vectors through a word-level accumulation mechanism to naturally adapt to amplitude-encoded input and avoid word frequency bias;
[0067] 2) A dual-channel semantic compression strategy is proposed for the first time, extracting semantic information in parallel using the one-hot and TF-IDF channels to improve model comprehensiveness.
[0068] 3) Constructed a combination of R x 、R y 、R zA three-stage variational quantum circuit consisting of a rotation gate, a local ring CNOT gate, and a fully connected CNOT gate stably maps quantum states into interpretable classical compression vectors.
[0069] 4) Through the process of vector splicing, angle encoding and classifier retraining, the final classification training after semantic fusion is achieved to improve the classification accuracy.
[0070] 4. This invention provides a practical new structure for QNLP, which is particularly suitable for semantic compression, feature modeling, information fusion and classification learning scenarios, and has broad engineering application prospects and scientific research value. BRIEF DESCRIPTION OF THE DRAWINGS
[0071] The accompanying drawings are used to provide further understanding of the present invention and constitute a part of the specification. They are used to explain the present invention together with the embodiments of the present invention and do not constitute a limitation of the present invention.
[0072] Figure 1 This is the overall flow chart of the quantum neural network model for dual-channel encoding and frequency measurement in the present invention.
[0073] Figure 2 This is an example diagram of the Ansatz model in the present invention.
[0074] Figure 3 Schematic diagram of one-hot coding layer compilation in the present invention.
[0075] Figure 4 This is a schematic diagram of the TF-IDF coding layer compilation in the present invention.
[0076] Figure 5 Schematic diagram of vector splicing in the present invention.
[0077] Figure 6 This is a schematic diagram of optimizing the classification result prediction in the present invention. DETAILED DESCRIPTION
[0078] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. Of course, the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0079] Example 1
[0080] See also Figure 1 and Figure 6This embodiment provides a technical solution: a quantum neural network optimization method based on dual-channel encoding and frequency measurement. In this embodiment, the model was validated using the MC dataset. The MC dataset contains 130 sentences composed of 17 different words, and the task objective is a binary classification task in the food and information technology fields. Next, two classic text encoding methods, one-hot encoding and term frequency-inverse document frequency (TF-IDF) encoding, are used to provide effective feature representation for subsequent quantum processing steps.
[0081] In the One-hot encoding process, each word is mapped to a high-dimensional sparse vector, where each position in the vector corresponds to a specific word. For each sentence, the system accumulates the One-hot vectors of all the words that appear in it to obtain a sentence-level sparse vector. This sparse vector clearly represents the presence of all terms in the sentence without introducing word frequency bias, thereby ensuring semantic integrity and interpretability. For TF-IDF encoding, the word frequency-inverse document frequency algorithm is used to process the words in each sentence to generate a weight vector that reflects the importance and uniqueness of each word in the sentence. In this way, a sparse sentence vector is generated for each sentence, which contains the contribution strength of different words in the sentence, such as Figure 3 and Figure 4 .
[0082] The two vectors obtained through one-hot encoding and TF-IDF encoding are then L2-norm normalized so that the sum of their squares is 1. After normalization, these vectors are input into the amplitude coding stage. Amplitude coding is a common quantum coding method that can map classical information (such as vectors) into quantum states. The amplitude coding process first maps the normalized classical vectors to the amplitude of quantum bits and then achieves feature compression through quantum operations. Specifically, the normalized vector of each sentence is mapped to a quantum state, which represents the characteristics of the sentence in the quantum system. Through amplitude coding, the input high-dimensional sparse vector is compressed into a low-dimensional quantum state, thereby reducing computational overhead and preserving important semantic information.
[0083] After the quantum states are generated, they are fed into the VQC for training. The VQC consists of multiple quantum gates, including the rotation gate (R yThe rotation gate is used to adjust the state of the quantum bit, while the CNOT gate is used to introduce entanglement between quantum bits. In the quantum circuit design, a single-bit rotation gate is first applied to adjust the state of each quantum bit. Next, a local CNOT gate ring is used to entangle adjacent quantum bits, thereby enhancing the relationship between the quantum bits. Then, in the second stage, the CNOT gate ring is applied again, and finally global entanglement is established through the fully connected CNOT gate. Such a quantum circuit design effectively improves the expressive power of the model while controlling the complexity of the model, making it suitable for the current NISQ device environment.
[0084] During training, the Adam optimizer is used to optimize all adjustable parameters in the quantum circuit, with a binary cross-entropy loss function as the objective function. This loss function effectively evaluates the performance of the classification model, ensuring that the classification error rate is minimized during training. Through multiple iterations, the optimization process gradually adjusts the parameters of the rotation gates and CNOT gates in the quantum circuit, thereby improving the model's classification capabilities.
[0085] After training is complete, the system converts the quantum state into a classical vector through a quantum measurement process. In this step, each qubit is measured multiple times, the results recorded, and the frequency of occurrences of the "1" state is counted. This frequency estimation method maps the qubit measurement results to classical values, resulting in a classical vector. This vector represents the state information of each qubit, serving as a bridge between quantum and classical computing and providing interpretable output for subsequent tasks.
[0086] Then, if Figure 5 As shown in Figure 1, the two compressed vectors generated by one-hot encoding and TF-IDF encoding are concatenated to form a new fused feature vector. To further improve classification performance, this fused feature vector is input into the angle encoding stage, where each vector element is mapped to the rotation angle of a revolving gate. After angle encoding, the fused feature vector enters the quantum circuit again, forming a secondary quantum classifier. This classifier uses the same VQC structure as before and is retrained based on the fused semantic space to optimize classification results.
[0087] Finally, the model output Figure 6 The classification results are shown in Figure 1, where 0 and 1 represent the two categories to which the sentence belongs, respectively. Experimental results show that this method achieves 100% classification accuracy on the MC dataset using only 30 trainable parameters, far exceeding existing methods. This demonstrates the excellent performance of our method under low-parameter and small-sample conditions and verifies its effectiveness in quantum text classification tasks.
[0088] Example 2
[0089] See also Figure 1 and Figure 6 The technical solution provided in this example was verified using the RP dataset. The RP dataset comes from the RELPRON semantic test set. The task objective is to classify complex sentence structures and determine the subject-object relationship in relative clauses. Similar to Example 1, this experiment used one-hot encoding and TF-IDF encoding to perform dual-channel feature extraction on the text, and then classified it using a quantum neural network.
[0090] In terms of text vectorization processing, this embodiment is the same as Example 1. First, each word is one-hot encoded, and the TF-IDF algorithm is used from another channel to assign an importance weight to each word. Then, the vectors of the two channels are normalized by the L2 norm and amplitude encoded to convert classical information into quantum states. The amplitude-encoded quantum state is input into the quantum neural network. After VQC training, the quantum circuit converts the quantum state into a classical vector by multiple measurement frequency estimation.
[0091] Unlike Example 1, the RP dataset contains a more diverse syntactic structure and more complex semantic relationships. Therefore, this example primarily improves the model's classification performance by optimizing quantum circuit design, particularly when processing data with complex syntactic structures. The training process uses the same Adam optimizer and binary cross-entropy loss function as in Example 1.
[0092] Ultimately, experimental results demonstrate that our method also demonstrates excellent classification accuracy on the RP dataset. Using only 42 trainable parameters, the model achieves 100% classification accuracy, significantly outperforming traditional methods. Compared to existing techniques, our method not only reduces the number of training parameters but also achieves higher classification performance on small sample datasets, demonstrating its effectiveness and robustness in complex sentence structures.
[0093] Example 3
[0094] See also Figure 1 and Figure 6 Based on the existing methods, this example uses the Amazon sentiment binary classification dataset for verification. The dataset contains 1,000 review samples, 800 of which are used for training and 200 for testing. The labels are binary: "1" represents positive sentiment and "0" represents negative sentiment.
[0095] In terms of text feature representation, this embodiment continues the dual-channel feature extraction mechanism but uses Word2Vec and Doc2Vec encoding instead of the one-hot encoding and TF-IDF encoding used in the previous two embodiments. Both encoding methods provide dense vector representations based on contextual modeling, better capturing semantic relationships between words and sentences, further enhancing the model's expressive power.
[0096] Word2Vec channel: Uses a pre-trained word vector model to encode each word in a sentence into a low-dimensional dense vector and average pools the word vectors in the sentence to form a sentence-level vector representation.
[0097] Doc2Vec channel: Utilizes the overall context of the sentence to map the complete sentence into a fixed-length vector, capturing richer semantic and structural features.
[0098] The vectors from both channels are then L2-normalized and fed into the amplitude encoding stage. Through amplitude encoding, the original dense vectors are compressed into quantum states, expressing classical feature information in the form of quantum bit amplitudes.
[0099] The subsequent steps are consistent with Examples 1 and 2. The generated quantum state is input into the VQC for training. The quantum circuit structure includes a three-segment Ansatz structure composed of a rotation gate, a local CNOT gate, and a fully connected CNOT gate, which has excellent local and global entanglement capabilities. The Adam optimizer is used during training to minimize the binary cross-entropy loss function and gradually adjust the trainable parameters in the quantum circuit to optimize classification performance.
[0100] After training, the qubits are measured using a multiple-measurement frequency estimation method, converting the quantum state into a classical compressed vector. The vectors generated by the two channels are concatenated and then, after angle encoding, fed back into the quantum circuit for secondary classifier training to enhance the classification capabilities of the fused semantic representation.
[0101] Experimental results show that, using only 42 training parameters, this method achieves 100% classification accuracy on the Amazon sentiment classification test set, demonstrating excellent small-sample learning and sentiment discrimination capabilities. Compared to traditional methods, this method demonstrates greater robustness and generalization in complex emotional semantic scenarios, further validating its practical application potential in natural language processing tasks such as sentiment analysis.
[0102] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A quantum neural network optimization method based on dual-channel coding and frequency measurement, characterized in that: The following steps are involved: S1. Use dual-channel feature extraction to vectorize text One-hot encoding: Each word is converted into a high-dimensional sparse vector through one-hot encoding. The one-hot vectors of all words appearing in the sentence are accumulated to generate a sentence-level sparse vector. TF-IDF encoding: This algorithm uses the term frequency-inverse document frequency algorithm to generate a vector for each word that reflects the semantic strength of the word. These vectors form the importance weight of each word in the sentence, extracting the semantic information of the sentence. S2. Prepare and compress quantum states using amplitude coding; Perform L2 norm normalization on the one-hot and TF-IDF encoded sparse vectors obtained from step S1 so that the sum of the squares of each vector is 1; Amplitude coding maps each normalized vector to a quantum bit, thereby converting classical information into a quantum state. Amplitude coding achieves feature compression by mapping classical data to the amplitude of the quantum bit, so that high-dimensional sparse vectors are compressed into low-dimensional quantum states. S3, Ansatz Construction and Quantum Circuit Training: Using a VQC structure, the amplitude-encoded quantum state is input into the quantum circuit. In the quantum circuit, a single-bit rotation gate is first applied to adjust the quantum bit state. Then, entanglement between quantum bits is introduced through local CNOT gates. Global information interaction between quantum bits is enhanced through fully connected CNOT gates. The Adam optimizer is used to optimize the parameters in the quantum circuit. The objective function uses binary cross entropy to minimize the classification error rate. Each channel's one-hot encoding and TF-IDF encoding channel are trained independently, and the final optimal parameters and circuit structure are saved. S4. Quantum Measurement and Frequency Estimation Multiple measurements are performed on each qubit, recording the frequencies of the "0" and "1" states, and mapping these frequencies to classical values. Through this frequency estimation method, the state of the qubit is converted into a classical vector; S5. Feature fusion and classifier training The two compressed classical vectors from the one-hot and TF-IDF channels are concatenated to form a new fused feature vector. The concatenated feature vector is then angle-encoded, mapping each vector element to the rotation angle of a revolving gate. This encoding enhances the adaptability of quantum circuits to the fused semantic space. The fused feature vector is input into the quantum circuit to form a secondary quantum classifier and trained again; S6. Result prediction and model optimization After the training is completed, the test data is classified by the quantum classifier, and the classification results of the test samples are output. The output 0 or 1 indicates the category to which the sentence belongs.
2. The quantum neural network optimization method based on dual-channel coding and frequency measurement according to claim 1, characterized in that: In step S3, Ansatz consists of three segments: first, a single bit R x The rotating gate layer assigns learnable parameters to each qubit; secondly, a local entanglement structure is applied, namely a ring CNOT gate, so that all adjacent qubits form a closed entangled network; then enter the second stage, apply R y The gate and execute the CNOT loop again; the third stage is R z Rotation gates and fully connected CNOT gates enable global information interaction between qubits; During the quantum circuit training process, the Adam optimizer is used to iteratively update the parameter gates in the quantum circuit. The objective function is the binary cross entropy, which is expressed as follows: If it is the average loss of a batch of samples, the function is rewritten as formula (2): Where y is the true label y∈{0,1}, is the predicted probability N is the sample size; This function is suitable for 0 / 1 classification problems. Each channel is trained independently and the final optimal parameters and circuit structure are saved. After training, in order to convert the quantum state into a classical vector that can be processed by downstream tasks, a custom quantum measurement method based on multiple measurement frequency estimation is introduced, as shown in formula (3): This method is used for the i-th quantum bit q i Perform M measurements and record the kth measurement result r i (k)∈{0,1}, the frequency f of state "1" is obtained statistically i (1) , and mapped to the classical value m of the corresponding dimension of the quantum bit i =-f i (1) ;Frequency f of state "0" i (0) Then it is mapped to the classic value m of the corresponding dimension i =f i (0) , thus forming an n-dimensional real vector.
3. The quantum neural network optimization method based on dual-channel coding and frequency measurement according to claim 1 is characterized in that: In step S1, dual-channel feature extraction is used to vectorize the text, including the following steps: S11. Use one-hot encoding to vectorize the unique words in each text and convert them into a high-dimensional sparse vector to form a word-level representation of the text. Then, add the one-hot vectors of the words corresponding to each sentence to form a one-hot encoded representation of the sentence. S12. Calculate the importance of each word in the text through TF-IDF encoding, generate a vector reflecting the semantic strength of each word, and form a sentence-level representation of the text.
4. The quantum neural network optimization method based on dual-channel coding and frequency measurement according to claim 1 is characterized in that: In step S2, the quantum state is prepared and compressed using amplitude coding, including the following steps: S21, perform L2 norm normalization on the text vector obtained by step S1 so that the sum of the squares of each vector is 1; S22. Amplitude coding technology is used to map the normalized classical vector to the quantum bit, convert the classical information of the text into a quantum state, and achieve feature compression through quantum computing.
5. The quantum neural network optimization method based on dual-channel coding and frequency measurement according to claim 1 is characterized in that: In step S4, quantum measurement and frequency estimation include the following steps: S41 performs multiple measurements on each qubit and records the state of the qubit as "0" or "1"; S42 counts the frequency of "0" and "1" in each measurement result to obtain the frequency distribution of the quantum bit state; S43 maps the measured frequency into a classical vector and converts the quantum state into a classical feature representation that can be used for subsequent tasks through frequency estimation methods.
6. The quantum neural network optimization method based on dual-channel coding and frequency measurement according to claim 1 is characterized in that: In step S5, feature fusion and classifier training include the following steps: S51, concatenating the classic vectors extracted by different channels, One-hot encoding and TF-IDF encoding obtained in steps S1, S2 and S4 to form a final fused feature vector; S52 performs angle encoding on the concatenated feature vectors, mapping each element to the rotation angle of a revolving gate, thus enhancing the adaptability of the quantum circuit to the fused semantic space. S53 inputs the fused feature vector into the quantum circuit, constructs a quadratic quantum classifier, and uses the binary cross entropy loss function to train the quantum circuit to optimize the classification performance of the classifier.
7. The quantum neural network optimization method based on dual-channel coding and frequency measurement according to claim 1 is characterized in that: In step S6, the result prediction and model optimization include the following steps: S61 classifies the test data using the trained quantum classifier and outputs the classification results of the test samples; S62 improves the robustness and accuracy of the model on small sample data sets by adjusting model parameters and optimizing algorithms; S63 evaluates the operational stability of the model on actual quantum computing devices and optimizes the model's resource consumption and training efficiency to meet the actual deployment requirements of NISQ devices.