Handwritten digit recognition method and system for noise-robust quantum neural network

CN122551369APending Publication Date: 2026-08-11NANTONG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-03-23
Publication Date
2026-08-11

AI Technical Summary

Technical Problem

[0005]本发明所要解决的技术问题是:针对现有技术的不足之处,提出一种阈值自校准、基于相邻训练周期梯度差缓冲累积、门类型感知、并按epoch周期触发更新的量子神经网络剪枝方法,以有效解决手写数字识别的问题,提高计算效率,降低计算能耗

Benefits of technology

[0041](1)本发明采用相邻epoch梯度差的缓冲累积量刻画参数在训练过程中的动态贡献,同时对每个参数维护并周期性更新自校准阈值。与仅依赖参数幅值或固定阈值的方案相比,该机制能够更稳定地区分持续参与优化的有效参数与长期贡献弱的冗余参数,减少早期误剪与性能塌陷概率;同时阈值随训练阶段自动调整,显著降低人工设定阈值带来的调参工作量,提高方法在不同数据集、不同线路结构下的适配性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122551369A_ABST
    Figure CN122551369A_ABST
Patent Text Reader

Abstract

This invention discloses a method and system for handwritten digit recognition using a noise-robust quantum neural network. The method includes: acquiring a handwritten digit image and performing block preprocessing; mapping the encoded angle parameters to quantum states and constructing a parameterized quantum circuit as a quantum neural network; training the quantum neural network, acquiring the parameter gradient after each round, updating the gradient difference buffer vector and adaptive pruning threshold, and constructing a candidate pruning set based on the condition that the buffer is less than the threshold; performing gate-aware pruning, updating the network, and fine-tuning the training; inputting the image to be recognized into the trained quantum neural network, measuring the expected value of the quantum state, inputting it into a classifier, and outputting the recognition result. This invention effectively reduces the number of high-noise two-qubit gates by accumulating gradient difference buffers to characterize the dynamic contribution of parameters, combined with threshold self-calibration and gate-aware priority pruning, thereby improving the robustness and accuracy of handwritten digit recognition using the quantum neural network.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of pattern recognition technology, specifically to a method and system for handwritten digit recognition based on a noise-robust quantum neural network. Background Technology

[0002] Handwritten digit recognition is a classic task in pattern recognition, widely used in postal sorting, bank check processing, form recognition, and other scenarios. Traditional methods, based on classical neural networks, have achieved high accuracy on datasets such as MNIST. However, with the expansion of data scale and the increasing demands for recognition accuracy, classical models face challenges in terms of computational efficiency and energy consumption, prompting researchers to explore new paths combining quantum computing and machine learning.

[0003] Quantum neural networks (CNNs) have shown potential advantages in classification tasks such as handwritten digit recognition due to their ability to combine parameterized quantum circuits with classical optimization algorithms. A typical CNN usually consists of data encoding circuits and multiple layers of parameterized quantum circuits. It extracts image features through the superposition and entanglement properties of quantum states, theoretically possessing stronger expressive power and parallel processing capabilities. However, under current conditions of noisy mesoscale quantum devices, the physical constraints of quantum hardware significantly limit the feasibility and robustness of CNNs. In existing mainstream quantum computing platforms such as superconducting and ion traps, the physical implementation complexity and average error rate of two-qubit gates are generally higher than those of single-qubit gates. These errors accumulate during the execution of the quantum circuits, causing the output of deep parameterized quantum circuits on real hardware to deviate from the ideal state, thus reducing the accuracy of handwritten digit recognition.

[0004] To address the aforementioned issues, existing pruning methods often employ fixed thresholds or static rules based on parameter angle amplitudes for parameter selection. Thresholds typically require repeated manual parameter tuning to achieve acceptable results across different datasets and line depths. Furthermore, existing methods often rely solely on parameter values ​​at a single moment, failing to reflect the continuous contribution of parameters to the optimized trajectory during training. Especially in noisy environments, static rules can easily misclassify key parameters that still contribute to noise resistance as redundant, leading to decreased recognition stability. Additionally, two-qubit gates typically have higher errors and greater resource costs, but existing pruning methods often fail to incorporate gate type into the pruning priority, resulting in an inability to effectively prioritize the reduction of redundancy associated with high-noise gates at the same pruning rate. Summary of the Invention

[0005] The technical problem this invention aims to solve is to address the shortcomings of existing technologies by proposing a quantum neural network pruning method that incorporates threshold self-calibration, gradient difference buffering accumulation based on adjacent training cycles, gate type awareness, and epoch-triggered updates. This method effectively solves the problem of handwritten digit recognition, improves computational efficiency, and reduces computational energy consumption. To address the above problem, this invention adopts the following technical solution:

[0006] First, this invention proposes a handwritten digit recognition method based on a noise-robust quantum neural network, comprising the following steps:

[0007] S1. Obtain the handwritten digit image to be recognized, perform block preprocessing on the image, and encode the pixel value of each image block into the rotation angle parameter of the quantum rotating door;

[0008] S2. The encoded angle parameters are mapped to quantum states through angle encoding and input into parameterized quantum circuits to construct a quantum neural network for handwritten digit recognition;

[0009] S3. Train the quantum neural network, obtain the parameter gradient after each round, update the gradient difference buffer vector and the adaptive pruning threshold, and construct a candidate pruning set.

[0010] S4. Perform gate-aware pruning, prioritizing pruning from the candidate pruning set corresponding to two-qubit gates. If insufficient, supplement from the candidate pruning set of single-qubit gates. After updating, fine-tune the training and repeat the pruning process until the stopping condition is met.

[0011] S5. Input the handwritten digit image to be recognized into the trained quantum neural network. After measuring the expected value of the quantum state, input it into the classifier and output the handwritten digit recognition result.

[0012] Preferably, step S1 involves performing block-based preprocessing on the image, specifically including:

[0013] The handwritten digit image is divided into blocks using a 4×4 sliding window with a step size of 4, resulting in 49 image blocks of 7×7 each, with each image block containing 16 pixel values; the handwritten digit image is a 28×28 grayscale image.

[0014] The 16-dimensional pixel vector of each image block is rearranged into a matrix form of 4 logical qubits × 4 features, with each logical qubit corresponding to 4 features.

[0015] Preferably, the parameterized quantum circuit adopts a 4-qubit structure, and each layer of the quantum circuit includes:

[0016] A ring-controlled rotation gate CRZ is applied sequentially to each qubit, and a single-qubit rotation gate RY is applied to each qubit.

[0017] Each layer of the circuit contains 4 two-qubit gate parameters and 4 single-qubit gate parameters, with a total number of parameters of 8L, where L is the number of circuit layers.

[0018] The two-qubit gate parameters are distinguished from the single-qubit gate parameters by an indexing rule: when the parameter index i satisfies (i mod 8) < 4, the parameter belongs to the two-qubit gate parameter set. Otherwise, it belongs to the single-qubit gate parameter set. .

[0019] Preferably, step S3 trains the quantum neural network, wherein the optimizer is Adagrad, the learning rate is lr = 0.2, the number of training epochs_pretrain = 3, the size of the training set subset is train_subset = 512, the size of the test set subset is test_subset = 256, and the batch size is batch_size = 32; the loss function is multi-class cross-entropy, and during the training process, the quantum model parameters θ and the classification head parameters are updated simultaneously to obtain the baseline weights θ_baseline and head_baseline.

[0020] Preferably, updating the gradient difference buffer vector in step S3 specifically includes:

[0021] At the end of each training round, the difference between the current gradient and the gradient of the previous round is compared and accumulated to obtain the gradient difference buffer vector B:

[0022] ,

[0023] Where |·| represents element-wise absolute value operation. g_prev is the gradient vector of the parameters obtained at the end of the t-th round; g_prev is the gradient vector of the previous round.

[0024] Preferably, updating the adaptive pruning threshold in step S3 specifically includes:

[0025] An independent pruning threshold τ_i is maintained for each parameter θ_i, and self-calibrated and updated based on the current gradient magnitude during each update. The threshold τ is calculated according to the following formula:

[0026] ,

[0027] Where ⊙ represents element-wise multiplication.

[0028] Preferably, the fine-tuning training after pruning in step S4 specifically includes:

[0029] After pruning, continue training for m epochs, or terminate fine-tuning early when the validation set performance recovers to a set threshold; simultaneously, enhance training stability through the following design:

[0030] Prune according to the training cycle to avoid frequent pruning in batches;

[0031] Set a minimum retention parameter ratio constraint to ensure that at least a preset percentage of parameters are not removed.

[0032] Meanwhile, this invention proposes a handwritten digit recognition system based on a noise-robust quantum neural network, comprising:

[0033] The image encoding module is configured to perform the following process: acquire the handwritten digit image to be recognized, perform block preprocessing on the image, and encode the pixel values ​​of each image block into the rotation angle parameters of the quantum rotating door;

[0034] The quantum neural network building module is configured to perform the following process: mapping the encoded angle parameters to quantum states through angle encoding, inputting them into parameterized quantum circuits, and building a quantum neural network for handwritten digit recognition;

[0035] The training and pruning preparation module is configured to perform the following process: train the quantum neural network, obtain the parameter gradients after each round, update the gradient difference buffer vector and the adaptive pruning threshold, and construct a candidate pruning set based on the condition that the buffer is less than the threshold.

[0036] The gate-aware pruning execution module is configured to perform the following process: perform gate-aware pruning, prioritize pruning from the candidate pruning set corresponding to two-qubit gates, and supplement from the candidate pruning set of single-qubit gates if insufficient, update the network, fine-tune the training and repeat the pruning process until the stopping condition is met.

[0037] The recognition output module is configured to perform the following process: input the handwritten digit image to be recognized into the trained quantum neural network, obtain the expected value of the quantum state by measurement, input it into the classifier, and output the handwritten digit recognition result.

[0038] Furthermore, the present invention proposes a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method as described in the present invention.

[0039] Finally, the present invention proposes an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the computer program is executed, it implements the steps of the method described in the present invention.

[0040] The present invention adopts the above technical solution, and compared with the prior art, it brings the following technical effects:

[0041] (1) This invention uses the buffer accumulation of gradient differences between adjacent epochs to characterize the dynamic contribution of parameters during training, while maintaining and periodically updating the self-calibration threshold for each parameter. Compared with schemes that rely solely on parameter amplitude or fixed thresholds, this mechanism can more stably distinguish between effective parameters that continuously participate in optimization and redundant parameters with weak long-term contributions, reducing the probability of early pruning and performance collapse; at the same time, the threshold is automatically adjusted during the training phase, significantly reducing the workload of parameter tuning caused by manually setting the threshold, and improving the adaptability of the method under different datasets and different line structures.

[0042] (2) This invention introduces a gate-aware mechanism in the pruning decision-making process, classifying parameters according to gate type and prioritizing the removal of parameters related to two-qubit gates during pruning. Since 2Q gates typically have higher error rates and are more prone to noise accumulation, this invention tends to reduce the parameter redundancy of high-noise gates under the same pruning scale, thereby reducing the noise sensitivity and execution failure risk of quantum circuits without significantly sacrificing accuracy, and improving the operability and inference reliability of quantum neural networks in the NISQ hardware environment.

[0043] (3) This invention triggers an update and performs pruning once per epoch to avoid frequent changes in the network structure at the step level, which would cause oscillations in the optimization trajectory. At the same time, the candidate set is sorted in ascending order by buffer size, and pruning is gradually performed starting from the parameter of “minimum gradient difference / minimum buffer value”. This allows pruning to start with the redundant terms that have the least impact on training, making the structural changes smoother. Furthermore, performance stability is maintained through fine-tuning after pruning. Attached Figure Description

[0044] Figure 1 This is a flowchart of the handwritten digit recognition method based on a noise-robust quantum neural network, which is the subject of this invention. Detailed Implementation

[0045] The technical solution of the present invention will be described in detail below with reference to the accompanying drawings.

[0046] Example 1: This example is a specific implementation of a handwritten digit recognition method for a noise-robust quantum neural network. Taking the MNIST dataset as an example, a 4-qubit QNN model is constructed, and the impact of two pruning strategies, literature pruning and the pruning of this invention, on noise resistance performance is compared under the framework of noise simulation and mapping. The model consists of a "data block encoding module + parameterized quantum circuit module + measurement and fully connected classification head module". For ease of description, the terms and symbols in this example are explained as follows: (1) Θ: the set / vector of all trainable parameters in the quantum neural network, (2) , : Represents the parameter subsets corresponding to the two-qubit gate and the one-qubit gate, respectively; (3) : The gradient vector of the parameters obtained at the end of the tth epoch; (4) g_prev: The gradient vector of the previous epoch; (5) B: The gradient difference buffer accumulation vector, B_i is used to represent the cumulative amount of gradient change of parameter θ_i in multiple epochs; (6) τ: The pruning threshold vector, τ_i is the self-calibration threshold of parameter θ_i; (7) A: The parameter activation mask, 1 for unpruned and 0 for pruned, used to ensure that the pruned parameters are not updated in subsequent training; (8) w: The pruning period, w=1 means that update and pruning are performed once per epoch; (9) k: The maximum number of parameters pruned in a single pruning.

[0047] like Figure 1 As shown, the steps of this method include:

[0048] S1. Obtain the handwritten digit image to be recognized, perform block preprocessing on the image, and encode the pixel value of each image block into the rotation angle parameter of the quantum rotating door;

[0049] S2. The encoded angle parameters are mapped to quantum states through angle encoding and input into parameterized quantum circuits to construct a quantum neural network for handwritten digit recognition;

[0050] S3. Train the quantum neural network, obtain the parameter gradient after each round, update the gradient difference buffer vector and the adaptive pruning threshold, and construct a candidate pruning set.

[0051] S4. Perform gate-aware pruning, prioritizing pruning from the candidate pruning set corresponding to two-qubit gates. If insufficient, supplement from the candidate pruning set of single-qubit gates. After updating, fine-tune the training and repeat the pruning process until the stopping condition is met.

[0052] S5. Input the handwritten digit image to be recognized into the trained quantum neural network. After measuring the expected value of the quantum state, input it into the classifier and output the handwritten digit recognition result.

[0053] Specifically, this invention uses an epoch as the basic cycle for training and pruning. Let the pruning cycle be w. When w=1, at the end of each epoch, it is determined whether to prune.

[0054] During the training process of the t-th epoch, a hybrid optimization strategy is used to iteratively update the parameters. To improve the stability and noise resistance of the pruning criterion, this invention obtains the gradient vector at the end of each epoch. This approach triggers an update and pruning only once at the end of the epoch. This avoids training oscillations caused by frequent pruning, helps maintain a smooth optimization trajectory, and thus improves the convergence and performance stability of the pruned model.

[0055] At the end of each training round, the difference between the current gradient and the gradient of the previous round is compared and accumulated to obtain the gradient difference buffer vector B:

[0056] ,

[0057] Where |·| represents element-wise absolute value operation. θ is the gradient vector of the parameter obtained at the end of the t-th round; g_prev is the gradient vector of the previous round. The larger B is, the more significant the gradient change of parameter θ is over multiple cycles, which usually means that the parameter is still actively participating in the optimization; conversely, if B is small for a long time, it indicates that the gradient change of the parameter is weak, the marginal contribution to the optimization process is low, and it is more likely to be a pruning redundant parameter.

[0058] To avoid the inability of B to represent contribution due to the lack of historical gradients in the initial stage, any of the following initialization strategies can be adopted during the first update: (a) Let g_prev = (a) Initialize B to a vector of all zeros; (b) Let g_prev = and initialize B to Or a small constant vector. The above initialization is an optional implementation and does not affect the core criteria of this invention. The relationship between state variables and updates is illustrated in Table 1.

[0059] Table 1

[0060]

[0061] Step S3 updates the adaptive pruning threshold, specifically including:

[0062] An independent pruning threshold τ_i is maintained for each parameter θ_i, and self-calibrated and updated based on the current gradient magnitude during each update. The threshold τ is calculated according to the following formula:

[0063] ,

[0064] Where ⊙ represents element-wise multiplication. This update rule automatically adjusts the threshold during the training phase: when the gradient magnitude of a parameter is large, its threshold decreases more significantly, making it more difficult to satisfy the candidate condition B < τ; when the gradient magnitude is small, the threshold decreases less significantly, making it more likely to enter the candidate set.

[0065] The candidate set construction and sorting rules are as follows:

[0066] After each update, a candidate set S is constructed based on the threshold and the buffer size:

[0067] .

[0068] Where A_i=1 indicates that the parameter has not yet been pruned. The candidate set is then sorted in ascending order by B_i.

[0069] This invention specifies that each round of pruning begins with the smallest buffer value after sorting, that is, parameters with the smallest B are pruned first. This strategy allows pruning to proceed step by step according to the parameters with the weakest dynamic contribution, reducing the impact of pruning on training stability and performance.

[0070] When performing pruning selection, this invention explicitly distinguishes between the 2Q gate parameters of a two-qubit gate and the 1Q gate parameters of a single-qubit gate, and follows the following gate-aware selection rule:

[0071] (1) Priority from In ∩ S_sorted, parameters are selected in ascending order by B;

[0072] (2) If the number of 2Q candidates is less than k, then from In ∩ S_sorted, fill in the blanks in ascending order of B;

[0073] (3) A maximum of k parameters can be removed in a single pruning.

[0074] The above strategy makes pruning more inclined to reduce the correlation parameters of high-noise 2Q gates at the same pruning rate, thereby more effectively reducing the overall noise sensitivity and hardware execution failure rate. Table 2 illustrates the candidate selection, sorting, and 2Q priority selection.

[0075] Table 2

[0076]

[0077] The pruning process is as follows:

[0078] Execute on the selected index set P:

[0079] 1. Freeze / deactivate: active[p]=False;

[0080] 2. Gradient blocking: Set the gradient of the clipped parameter to 0 during backpropagation training;

[0081] 3. Keep parameters at 0: Set the parameter value to 0 after each update step;

[0082] To offset the instantaneous impact of pruning on the model's expressive power, this invention performs fine-tuning training after each pruning iteration. Fine-tuning can employ a fixed number of epochs or an adaptive number of epochs strategy, for example: continuing training for m epochs after pruning; or ending fine-tuning early when the validation set performance recovers to a set threshold. Furthermore, this invention enhances training stability through the following design: (a) pruning by epoch period to avoid frequent step-level pruning; (b) setting a minimum retention constraint to retain at least a certain proportion of parameters to prevent over-pruning from causing model failure.

[0083] Finally, the pruning process stops when the maximum number of training rounds is reached.

[0084] In this embodiment, the input is a 28×28 grayscale image. First, a sliding window is used to divide the image into blocks with 4 patches and 4 strides, resulting in 7×7=49 patches. Each patch is 4×4, containing 16 pixel values. For each patch, the 16-dimensional vector is rearranged into a 4 qubits×4 features matrix: each logical qubit corresponds to 4 features, used for subsequent angle encoding. The same image requires 49 quantum circuit operations to obtain 49 sets of measurement outputs; each output contains 4 Pauli-Z expectation values, which are then concatenated to obtain 4×49=196-dimensional features, which are then fed into the classification head to complete 10 classifications.

[0085] This embodiment uses a 4-qubit parameterized quantum circuit. The encoding and calculation of each patch are as follows: For the w-th qubit, apply RY(π·x[w,0]), RX(π·x[w,1]), RZ(π·x[w,2]), and RY(π·x[w,3]) sequentially to achieve angular encoding of the 16-dimensional patch features. Here, w is the index number of the qubit; x[w,i] is the element in the w-th row and i-th column of the input feature matrix x, used to represent the i-th input feature corresponding to the w-th qubit; π·x[w,i] represents the rotation angle determined by the input feature; RY, RX, and RZ are single-qubit rotation gates; the rotation gates act sequentially on the corresponding qubits, thereby mapping classical features to the quantum state space. For each layer:

[0086] (a) First, apply a ring-shaped controlled rotating gate CRZ(θ) to form adjacent entanglement and close the loop, 0→1→2→3→0, for a total of 4 2Q parameters;

[0087] (b) Apply RY(θ) to each qubit, resulting in four 1Q parameters. Therefore, the number of parameters per layer is 8, and the total number of parameters is n_var = 8L. Since the first four θ parameters in each layer are used for 2Q gates and the last four θ parameters are used for 1Q gates, the 2Q parameters can be labeled using an index rule: is_2q(i) = True if and only if (i mod 8) < 4. This rule prioritizes 2Q parameters when pruning.

[0088] The quantum neural network was trained without pruning. The optimizer used was Adagrad, the learning rate lr = 0.2, the number of training epochs_pretrain = 3, the size of the training subset was train_subset = 512, the size of the test subset was test_subset = 256, and the batch size was batch_size = 32. The loss function was multi-class cross-entropy. During training, the quantum model parameters θ and the classification head parameters were updated simultaneously to obtain the baseline weights θ_baseline and head_baseline.

[0089] This embodiment uses the noiseless inference output as the reference sequence `noiseless_preds`. Further, on the same test sample set, inference is performed on the original model, the pruned model, and the model after pruning and completing noise robust mapping under the noisy model, respectively, to obtain the noise baseline prediction sequence `noisy_baseline`, the noise pruned prediction sequence `noisy_pruned`, and the noise robust quantum neural network prediction sequence `noisy_nrqnn`. This embodiment uses the similarity index to evaluate the consistency between the prediction results under noisy conditions and the noiseless reference results. The calculation formula is as follows:

[0090]

[0091] Where M is the number of test samples, and the final output is a percentage. After pruning, NR-QNN mapping is further performed: first, the logical bits on the test samples are sorted by sensitivity, and the higher the sensitivity, the higher the priority for protection; then, the physical bits are extracted from the fake backend and sorted by reliability; the highly sensitive logical bits are mapped to the highly reliable physical bits, and after obtaining the initial mapping layout, noisy inference is performed.

[0092] The performance of NR-QNN is shown in Table 3:

[0093] Table 3

[0094]

[0095] The effects of the method of the present invention are shown in Table 4:

[0096] Table 4

[0097]

[0098] At the same number of layers, the consistency rate of literature pruning significantly decreased at layers L2 and L3, indicating that using only small angle as the redundancy criterion may mistakenly delete rotating gates that still contribute to noise suppression. The method of this invention, through "threshold self-calibration + gradient difference buffer accumulation + candidate pruning starting from the minimum buffer value + 2Q priority + progressive pruning by epoch period," significantly improves the consistency rate at layers L1 / L3, indicating that this pruning method better preserves parameters critical to output stability while prioritizing the reduction of high-noise 2Q gate-related redundancy, thereby improving robustness in noisy environments.

[0099] Example 2: This example proposes a handwritten digit recognition system based on a noise-robust quantum neural network, comprising:

[0100] The image encoding module is configured to perform the following process: acquire the handwritten digit image to be recognized, perform block preprocessing on the image, and encode the pixel values ​​of each image block into the rotation angle parameters of the quantum rotating door;

[0101] The quantum neural network building module is configured to perform the following process: mapping the encoded angle parameters to quantum states through angle encoding, inputting them into parameterized quantum circuits, and building a quantum neural network for handwritten digit recognition;

[0102] The training and pruning preparation module is configured to perform the following process: train the quantum neural network, obtain the parameter gradients after each round, update the gradient difference buffer vector and the adaptive pruning threshold, and construct a candidate pruning set based on the condition that the buffer is less than the threshold.

[0103] The gate-aware pruning execution module is configured to perform the following process: perform gate-aware pruning, prioritize pruning from the candidate pruning set corresponding to two-qubit gates, and supplement from the candidate pruning set of single-qubit gates if insufficient, update the network, fine-tune the training and repeat the pruning process until the stopping condition is met.

[0104] The recognition output module is configured to perform the following process: input the handwritten digit image to be recognized into the trained quantum neural network, obtain the expected value of the quantum state by measurement, input it into the classifier, and output the handwritten digit recognition result.

[0105] Example 3: This example proposes a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method described in this invention.

[0106] Example 4: This example proposes an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the computer program is executed, it implements the steps of the method described in this invention.

[0107] It should be noted that the processing flow of embodiments 2-4 corresponds to the specific steps of the method provided in embodiment 1 of the present invention, and has the corresponding functional modules and beneficial effects of the method. Technical details not described in detail in this embodiment can be found in the method provided in embodiment 1 of the present invention.

[0108] The program code used to implement the methods of this application may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing device, such that when executed by the processor or controller, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0109] The specific implementation schemes described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific implementation schemes of the present invention and are not intended to limit the scope of the present invention. Any equivalent changes and modifications made by those skilled in the art without departing from the concept and principles of the present invention should fall within the scope of protection of the present invention.

Claims

1. A method for handwritten digit recognition using a noise-robust quantum neural network, the method comprising: Includes the following steps: S1. Obtain the handwritten digit image to be recognized, perform block preprocessing on the image, and encode the pixel value of each image block into the rotation angle parameter of the quantum rotating door; S2. The encoded angle parameters are mapped to quantum states through angle encoding and input into parameterized quantum circuits to construct a quantum neural network for handwritten digit recognition; S3. Train the quantum neural network, obtain the parameter gradient after each round, update the gradient difference buffer vector and the adaptive pruning threshold, and construct a candidate pruning set. S4. Perform gate-aware pruning, prioritizing pruning from the candidate pruning set corresponding to two-qubit gates. If insufficient, supplement from the candidate pruning set of single-qubit gates. After updating, fine-tune the training and repeat the pruning process until the stopping condition is met. S5. Input the handwritten digit image to be recognized into the trained quantum neural network. After measuring the expected value of the quantum state, input it into the classifier and output the handwritten digit recognition result.

2. The method of claim 1, wherein, Step S1 involves preprocessing the image into blocks, specifically including: The handwritten digit image is divided into blocks using a 4×4 sliding window with a step size of 4, resulting in 49 image blocks of 7×7 each, with each image block containing 16 pixel values; the handwritten digit image is a 28×28 grayscale image. The 16-dimensional pixel vector of each image block is rearranged into a matrix form of 4 logical qubits × 4 features, with each logical qubit corresponding to 4 features.

3. The method of claim 1, wherein, The parameterized quantum circuit adopts a 4-qubit structure, and each layer of the quantum circuit includes: A ring-controlled rotation gate CRZ is applied sequentially to each qubit, and a single-qubit rotation gate RY is applied to each qubit. Each layer of the circuit contains 4 two-qubit gate parameters and 4 single-qubit gate parameters, with a total number of parameters of 8L, where L is the number of circuit layers. The two-qubit gate parameters are distinguished from the single-qubit gate parameters by an indexing rule: when the parameter index i satisfies (i mod 8) < 4, the parameter belongs to the two-qubit gate parameter set. Otherwise, it belongs to the single-qubit gate parameter set. .

4. The method of claim 1, wherein, Step S3 trains the quantum neural network. The optimizer is Adagrad, the learning rate is lr = 0.2, the number of training epochs_pretrain = 3, the size of the training subset is train_subset = 512, the size of the test subset is test_subset = 256, and the batch size is batch_size = 32. The loss function is multi-class cross-entropy. During training, the quantum model parameters θ and the classification head parameters are updated simultaneously to obtain the baseline weights θ_baseline and head_baseline.

5. The method of claim 4, wherein, Step S3 updates the gradient difference buffer vector, specifically including: At the end of each training round, the difference between the current gradient and the gradient of the previous round is compared and accumulated to obtain the gradient difference buffer vector B: , where | · | denotes the element-wise absolute value operation, is the parameter gradient vector at the end of the t-th iteration; g prev is the gradient vector of the previous iteration.

6. The method of claim 5, wherein, Step S3 updates the adaptive pruning threshold, specifically including: An independent pruning threshold τ_i is maintained for each parameter θ_i, and self-calibrated and updated based on the current gradient magnitude during each update. The threshold τ is calculated according to the following formula: , Where ⊙ represents element-wise multiplication.

7. The method of claim 6, wherein, Step S4, post-pruning fine-tuning training, specifically includes: After pruning, continue training for m epochs, or terminate fine-tuning early when the validation set performance recovers to a set threshold; simultaneously, enhance training stability through the following design: Prune according to the training cycle to avoid frequent pruning in batches; Set a minimum retention parameter ratio constraint to ensure that at least a preset percentage of parameters are not removed.

8. A handwritten digit recognition system based on a noise-robust quantum neural network, characterized in that, include: The image encoding module is configured to perform the following process: acquire the handwritten digit image to be recognized, perform block preprocessing on the image, and encode the pixel values ​​of each image block into the rotation angle parameters of the quantum rotating door; The quantum neural network building module is configured to perform the following process: mapping the encoded angle parameters to quantum states through angle encoding, inputting them into parameterized quantum circuits, and building a quantum neural network for handwritten digit recognition; The training and pruning preparation module is configured to perform the following process: train the quantum neural network, obtain the parameter gradients after each round, update the gradient difference buffer vector and the adaptive pruning threshold, and construct a candidate pruning set based on the condition that the buffer is less than the threshold. The gate-aware pruning execution module is configured to perform the following process: perform gate-aware pruning, prioritize pruning from the candidate pruning set corresponding to two-qubit gates, and supplement from the candidate pruning set of single-qubit gates if insufficient, update the network, fine-tune the training and repeat the pruning process until the stopping condition is met. The recognition output module is configured to perform the following process: input the handwritten digit image to be recognized into the trained quantum neural network, obtain the expected value of the quantum state by measurement, input it into the classifier, and output the handwritten digit recognition result.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1 to 7.

10. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the computer program is executed, it implements the steps of the method as described in any one of claims 1 to 7.