A quantized neural network fault-tolerant enhancement method based on weight elastic mapping
By calculating the weight perturbation elasticity and mapping function of the quantized neural network and limiting the weight range, the vulnerability of quantized neural networks in embedded devices to attacks is solved, improving fault tolerance and maintaining performance.
Patent Information
- Application Number
- CN202410754226.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-12
- Publication Date
- 2026-11-20
- Estimated Expiration
- 2044-06-12
AI Technical Summary
Quantized neural networks are vulnerable to bit-flip attacks in embedded devices, resulting in high error rates. Existing software-level fault tolerance enhancement techniques require retraining, leading to high time costs and performance degradation.
By calculating the weight perturbation elasticity of the quantized neural network model, the weight mapping parameters and functions are determined, and the range of weight values is limited to improve fault tolerance and avoid additional overhead.
It improves the fault tolerance of quantized neural networks, making them suitable for computer vision applications in embedded devices, reducing error rates while maintaining model performance.
Smart Images

Figure CN118586468B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of network security technology, specifically relating to a method for enhancing the fault tolerance of quantized neural networks based on weighted elastic mapping. Background Technology
[0002] Quantized Neural Networks (QDNNs) are deployed in embedded devices, enabling deep learning to be widely applied across various fields, such as computer vision applications. These programs primarily perform classification tasks on input samples; that is, given an input image, the quantized neural network model infers and outputs its corresponding category in a very short time.
[0003] Because resource-constrained embedded devices lack sufficient resources to ensure the implementation of data integrity checks, they cannot provide adequate security protection, posing a significant challenge to system security. The inherent fault tolerance of quantized neural networks cannot withstand hardware failures. In the more challenging environments of mobile and embedded systems, soft errors caused by manufacturing variability, aging, increased temperature gradients, and radiation can lead to even higher error rates. Quantized neural networks are also vulnerable to fault injection attacks, the most typical being bit-flip attacks (BFA). Progressive search bit-flip attacks (PBFA) can completely destroy the performance of quantized neural networks with just a few attacks.
[0004] Fault tolerance enhancement technologies are divided into software and hardware layers. Hardware-level fault tolerance enhancement technologies incur high hardware costs, are difficult to adapt to every hardware device, and lack universality. Software-level fault tolerance enhancement technologies can be deployed on different hardware, offering lower costs and greater practicality.
[0005] Existing research reduces the impact of weight perturbations and increases the tolerance threshold for weight errors by limiting the range of weight variations. First, the weight change is propagated to other weights within the same group through averaging. Then, the average is clipped to different quantization levels to further reduce weight changes caused by bit flips. Finally, fine-tuning is performed during training to improve the model's accuracy. This demonstrates that limiting the range of weight numerical representation helps improve the fault tolerance of quantized neural network models.
[0006] The aforementioned method requires retraining and fine-tuning, which incurs significant time costs and inevitably degrades model performance. This is because the method lacks analysis of the elasticity of weight perturbations, relying solely on averaging to limit the weight range, thus failing to yield precise results. Considering that quantized neural network models possess inherent fault tolerance, capable of tolerating a certain degree of weight errors, analyzing the elasticity of weight perturbations and thus limiting the range of weight elasticity can effectively improve the model's fault tolerance. Summary of the Invention
[0007] To address the aforementioned technical problems, this invention provides a fault-tolerant enhancement method for quantized neural networks based on weighted elastic mapping, which solves the problem of errors occurring in computer vision applications based on quantized neural networks deployed in embedded devices due to bit-flip attacks.
[0008] The technical solution adopted in this invention is: a fault-tolerant enhancement method for quantized neural networks based on weight elastic mapping, the specific steps of which are as follows:
[0009] S1. Select an image dataset to calculate the weight perturbation elasticity of the quantized neural network model;
[0010] S2. Based on the quantization bit width selected in the actual application and the weight perturbation elasticity calculated in step S1, calculate the weight mapping parameters.
[0011] S3. Determine the weight mapping function based on the weight perturbation elasticity and weight mapping parameters;
[0012] S4. During the operation of the network model, the weights are calculated according to the weight mapping function, and the calculated weight parameters are used for inference to complete the fault tolerance enhancement.
[0013] Furthermore, step S1 is specifically as follows:
[0014] S11. Load the image dataset and quantize the neural network model to confirm the type of image classification task;
[0015] Image classification tasks include binary classification and multi-class classification.
[0016] S12. Load one input data point from the image dataset, perform model inference, and record the correct inference result of the model.
[0017] Select an image dataset as input to the quantized neural network model. Input one data point at a time for inference, calculate the perturbation, add the perturbation to the weight parameters, and record the accumulated perturbation. Repeat the inference for this data until the classification result changes.
[0018] The quantized neural network model is deployed in an embedded device, and its computer vision application is used for the classification task of input samples. That is, for an input image data, the neural network model infers and outputs the category to which it should belong.
[0019] S13. Determine the type of image classification task. If it is a multi-class classification task, proceed to step S14. If it is a binary classification task, proceed to step S15.
[0020] S14. For each distinct category, calculate the nearest category plane, using the following expression:
[0021]
[0022]
[0023]
[0024] in, Indicates the initial number of... Weight parameters in the next iteration Represents the classification plane. Represents the weight gradient. Indicates the result of reasoning. Indicates the first Each classification result This indicates that the classification is correct. This indicates a incorrect classification. Indicates input data, This represents the bias parameter.
[0025] S15. Calculate the weight perturbation;
[0026] The distance from the weight parameters to the boundary of the binary classification weight space is calculated and recorded in the following expression:
[0027]
[0028] in, Indicates the first The perturbation in the next iteration Represents the weight gradient. This indicates the classification result.
[0029] Calculation to the classification plane under multi-class classification The perturbation is recorded, and the expression is as follows:
[0030]
[0031] in, Indicates in Results under planar classification This represents the corresponding weight gradient.
[0032] S16, Disturbance Add to the weight parameters and update the weight parameters;
[0033] S17. Perform inference again using the updated weight parameters after adding perturbation, and compare it with the initial correct inference result. If they are consistent, proceed to step S13; if the results are different, proceed to step S18.
[0034] S18. Accumulate and calculate the recorded disturbances. The weight perturbation elasticity is obtained and recorded, and it is determined whether all data in the image dataset has been inferred. If not all data has been inferred, proceed to step S12 to perform the next data calculation; otherwise, proceed to step S19.
[0035] S19. After calculating the weighted perturbation elasticity for each data point in the input image dataset, the minimum weighted perturbation elasticity for each layer is taken to obtain the weighted perturbation elasticity for each layer. .
[0036] Furthermore, step S2 is specifically as follows:
[0037] S21. Calculate the quantization bit width range;
[0038] To select the desired quantization bit width, use the following expression:
[0039]
[0040] in, This indicates the weight under the selected quantization bit width. Indicates the minimum value in the range. Indicates the maximum value within the range.
[0041] S22. Confirm the weight elasticity range;
[0042] The weight elasticity range is calculated based on the weight perturbation elasticity and the original weights, as shown in the following expression:
[0043]
[0044]
[0045] in, This represents the mapped weight parameters. This represents the original correct weight parameters. This indicates the tolerable weight.
[0046] S23. Calculate the two weight mapping parameters required for the weight mapping function;
[0047]
[0048] in, and This represents the weight mapping parameters.
[0049] Furthermore, step S3 is specifically as follows:
[0050] By obtaining the weight perturbation elasticity, we can derive the range of weight parameters that maintain the model's accuracy. The weight mapping function expression is as follows:
[0051]
[0052] After obtaining the weight mapping parameters based on step S2, the weight mapping function expression is rewritten as follows:
[0053]
[0054] Furthermore, step S4 is specifically as follows:
[0055] S41. Calculate the mapped weights based on the weight mapping function obtained in step S3;
[0056] S42. Determine whether the mapping result is less than the maximum value of the quantization bit width range. If it is less, proceed to step S43. If it is greater, proceed to step S44.
[0057] S43. The mapping result is truncated and rounded down as a weight parameter;
[0058] S44. The maximum quantization bit width is used as a weighting parameter;
[0059] S45. Based on the weight parameters obtained in steps S41-S44, perform inference to complete the fault tolerance enhancement.
[0060] The beneficial effects of this invention are as follows: The method of this invention first uses the relevant image dataset to calculate the weight perturbation elasticity of the quantized neural network model. Then, based on the selected quantization bit width and weight perturbation elasticity range, it calculates the weight mapping parameters. Finally, it determines the weight mapping function based on the weight perturbation elasticity and the weight mapping parameters, and performs weight mapping during inference to improve the model's fault tolerance. This method, based on the weight perturbation elasticity of the quantized neural network model, uses mapping calculations to limit the numerical range of the weights, thereby avoiding numerical variations, protecting the correctness of the quantized neural network, improving the model's fault tolerance, and achieving fault tolerance enhancement for the neural network. It is suitable for enhancing the fault tolerance of computer vision applications based on quantized neural network models used in embedded devices, and does not incur much additional overhead during operation. Attached Figure Description
[0061] Figure 1 This is a flowchart of a fault-tolerant enhancement method for quantized neural networks based on weight elastic mapping according to the present invention.
[0062] Figure 2 This is a flowchart of the weighted perturbation elasticity calculation in an embodiment of the present invention.
[0063] Figure 3 This is a flowchart of the weight mapping parameter calculation in an embodiment of the present invention.
[0064] Figure 4 This is a flowchart illustrating the calculation of the weight mapping function in an embodiment of the present invention. Detailed Implementation
[0065] The method of the present invention will be further described below with reference to the accompanying drawings and embodiments.
[0066] like Figure 1 The flowchart of a fault-tolerant enhancement method for quantized neural networks based on weight elastic mapping according to the present invention is shown below. The specific steps are as follows:
[0067] S1. Select an image dataset to calculate the weight perturbation elasticity of the quantized neural network model;
[0068] S2. Based on the quantization bit width selected in the actual application and the weight perturbation elasticity calculated in step S1, calculate the weight mapping parameters.
[0069] S3. Determine the weight mapping function based on the weight perturbation elasticity and weight mapping parameters;
[0070] S4. During the operation of the network model, the weights are calculated according to the weight mapping function, and the calculated weight parameters are used for inference to complete the fault tolerance enhancement.
[0071] The elasticity of weight perturbation reflects the inherent fault tolerance of the quantized neural network model. Within this elasticity range, model errors will not affect the final result. Outside this elasticity range, errors in weight parameters will lead to errors in the result.
[0072] Weight perturbation elasticity calculation: Image classification tasks are divided into binary classification and multi-class classification. From the perspective of high-dimensional space, they are represented by different weight space boundaries. If the weight parameters are in the correct space, and the perturbation causes them to cross the weight space boundary, then the classification result will be wrong. The model's weight parameters cannot tolerate this perturbation. Therefore, by establishing the relationship between the weight parameters and the classification result, and by calculating the distance from the weight parameters to the weight space boundary, the weight perturbation elasticity can be obtained.
[0073] like Figure 2 As shown, in this embodiment, step S1 is specifically as follows:
[0074] S11. Load the image dataset and quantize the neural network model to confirm the type of image classification task;
[0075] Image classification tasks include binary classification and multi-class classification. Binary and multi-class classification employ different methods for calculating the weight perturbation elasticity.
[0076] S12. Load one input data point from the image dataset, perform model inference, and record the correct inference result of the model.
[0077] Select an image dataset as input to the quantized neural network model. Input one data point at a time for inference, calculate the perturbation, add the perturbation to the weight parameters, and record the accumulated perturbation. Repeat the inference for this data until the classification result changes.
[0078] The quantized neural network model is deployed in an embedded device, and its computer vision application is used for the classification task of input samples. That is, for an input image data, the neural network model infers and outputs the category to which it should belong.
[0079] S13. Determine the type of image classification task. If it is a multi-class classification task, proceed to step S14. If it is a binary classification task, proceed to step S15.
[0080] S14. For each distinct category, calculate the nearest category plane, using the following expression:
[0081]
[0082]
[0083]
[0084] in, Indicates the initial number of... Weight parameters in the next iteration Represents the classification plane. Represents the weight gradient. Indicates the result of reasoning. Indicates the first Each classification result This indicates that the classification is correct. This indicates a incorrect classification. Indicates input data, This represents the bias parameter.
[0085] S15. Calculate the weight perturbation;
[0086] The distance from the weight parameters to the boundary of the binary classification weight space is calculated and recorded in the following expression:
[0087]
[0088] in, Indicates the first The perturbation in the next iteration Represents the weight gradient. This indicates the classification result.
[0089] Calculation to the classification plane under multi-class classification The perturbation is recorded, and the expression is as follows:
[0090]
[0091] in, Indicates in Results under planar classification This represents the corresponding weight gradient.
[0092] S16, Disturbance Add to the weight parameters and update the weight parameters;
[0093] S17. Perform inference again using the updated weight parameters after adding perturbation, and compare it with the initial correct inference result. If they are consistent, proceed to step S13; if the results are different, proceed to step S18.
[0094] S18. Accumulate and calculate the recorded disturbances. The weight perturbation elasticity is obtained and recorded, and it is determined whether all data in the image dataset has been inferred. If not all data has been inferred, proceed to step S12 to perform the next data calculation; otherwise, proceed to step S19.
[0095] S19. After calculating the weight perturbation elasticity for each data point in the input image dataset, the minimum value of the weight perturbation elasticity for each layer (fine-grained for each layer of the network) is taken to obtain the weight perturbation elasticity for each layer. .
[0096] Weight mapping function calculation: After obtaining the weight perturbation elasticity, the range of weight parameters that maintain the model's accuracy can be derived. Therefore, the weight mapping function can be initially established as follows: This involves two parameters. and This is a parameter that defines the range, ensuring that the final value remains within the elasticity of the weighted perturbation.
[0097] like Figure 3 As shown, in this embodiment, step S2 is specifically as follows:
[0098] S21. Calculate the quantization bit width range;
[0099] Confirm the quantization bit width to be selected (the quantization bit width determines the entire representation range of the weight parameters), as shown in the following expression:
[0100]
[0101] in, This indicates the weight under the selected quantization bit width. Indicates the minimum value in the range. Indicates the maximum value within the range.
[0102] S22. Confirm the weight elasticity range;
[0103] The weight elasticity range is calculated based on the weight perturbation elasticity and the original weights, as shown in the following expression:
[0104]
[0105]
[0106] in, This represents the mapped weight parameters. This represents the original correct weight parameters. This indicates the tolerable weight.
[0107] S23. Calculate the two weight mapping parameters required for the weight mapping function;
[0108]
[0109] in, and This represents the weight mapping parameters.
[0110] In this embodiment, step S3 is specifically as follows:
[0111] By obtaining the weight perturbation elasticity, we can derive the range of weight parameters that maintain the model's accuracy. The weight mapping function expression is as follows:
[0112]
[0113] After obtaining the weight mapping parameters based on step S2, the weight mapping function expression is rewritten as follows:
[0114]
[0115] like Figure 4 As shown, in this embodiment, step S4 is specifically as follows:
[0116] S41. Calculate the mapped weights based on the weight mapping function obtained in step S3;
[0117] S42. Determine whether the mapping result is less than the maximum value of the quantization bit width range. If it is less, proceed to step S43. If it is greater, proceed to step S44.
[0118] S43. The mapping result is truncated and rounded down as a weight parameter;
[0119] S44. The maximum quantization bit width is used as a weighting parameter;
[0120] S45. Based on the weight parameters obtained in steps S41-S44, perform inference to complete the fault tolerance enhancement.
[0121] In summary, the method of this invention, based on the weight perturbation elasticity of the quantized neural network model, uses mapping calculation to limit the numerical range of the weights, thereby avoiding numerical changes, protecting the correctness of the quantized neural network, improving the fault tolerance of the model, and achieving fault tolerance enhancement for the neural network. It is suitable for enhancing the fault tolerance of computer vision applications based on quantized neural network models used in embedded devices, and does not cause too much additional overhead during operation.
[0122] Those skilled in the art will recognize that the embodiments described herein are intended to help the reader understand the principles of the invention, and should be understood that the scope of protection of the invention is not limited to such specific statements and embodiments. Various modifications and variations can be made to the invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the invention should be included within the scope of the claims of the invention.
Claims
1. A fault-tolerant enhancement method for quantized neural networks based on weight elastic mapping, the specific steps of which are as follows: S1. Select an image dataset to calculate the weight perturbation elasticity of the quantized neural network model; S2. Based on the quantization bit width selected in the actual application and the weight perturbation elasticity calculated in step S1, calculate the weight mapping parameters. S3. Determine the weight mapping function based on the weight perturbation elasticity and weight mapping parameters; S4. During the operation of the network model, the weights are calculated according to the weight mapping function, and the calculated weight parameters are used for inference to complete the fault tolerance enhancement.
2. The method for enhancing the fault tolerance of a quantized neural network based on weight elastic mapping according to claim 1, characterized in that, The specific steps of S1 are as follows: S11. Load the image dataset and quantize the neural network model to confirm the type of image classification task; Image classification tasks include two types: binary classification and multi-class classification. S12. Load one input data point from the image dataset, perform model inference, and record the correct inference result of the model. Select an image dataset as input to the quantized neural network model. Input one data point at a time for inference, calculate the perturbation, add the perturbation to the weight parameters, and record the accumulated perturbation. Repeat the inference for this data until the classification result changes. The quantized neural network model is deployed in an embedded device, and its computer vision application is used for the classification task of input samples. That is, for an input image data, the neural network model infers and outputs the category to which it should belong. S13. Determine the type of image classification task. If it is a multi-class classification task, proceed to step S14. If it is a binary classification task, proceed to step S15. S14. For each distinct category, calculate the nearest category plane, using the following expression: ; ; ; in, Indicates the initial number of... Weight parameters in the next iteration Represents the classification plane. Represents the weight gradient. Indicates the result of reasoning. Indicates the first Each classification result This indicates that the classification is correct. This indicates a incorrect classification. Indicates input data, Indicates the bias parameter; S15. Calculate the weight perturbation; The distance from the weight parameters to the boundary of the binary classification weight space is calculated and recorded in the following expression: ; in, Indicates the first The perturbation in the next iteration Represents the weight gradient. Indicates the classification result; Calculation to the classification plane under multi-class classification The perturbation is recorded, and the expression is as follows: ; in, Indicates in Results under planar classification This represents the corresponding weight gradient; S16, Disturbance Add to the weight parameters and update the weight parameters; S17. Perform inference again using the updated weight parameters after adding perturbation, and compare it with the initial correct inference result. If they are consistent, proceed to step S13; if the results are different, proceed to step S18. S18. Accumulate and calculate the recorded disturbances. The weight perturbation elasticity is obtained and recorded, and it is determined whether all data in the image dataset has been inferred. If not all data has been inferred, proceed to step S12 to perform the next data calculation; otherwise, proceed to step S19. S19. After inputting all data in the image dataset, calculate the weighted perturbation elasticity for each data point. Then, take the minimum value of the weighted perturbation elasticity for each layer's weight parameters to obtain the weighted perturbation elasticity for each layer. .
3. The method for enhancing the fault tolerance of a quantized neural network based on weight elastic mapping according to claim 2, characterized in that, Step S2 is as follows: S21. Calculate the quantization bit width range; To select the desired quantization bit width, use the following expression: ; in, This indicates the weight under the selected quantization bit width. Indicates the minimum value in the range. Indicates the maximum value within the range; S22. Confirm the weight elasticity range; The weight elasticity range is calculated based on the weight perturbation elasticity and the original weights, as shown in the following expression: ; ; in, This represents the mapped weight parameters. This represents the original correct weight parameters. Indicates the tolerable weight; S23. Calculate the two weight mapping parameters required for the weight mapping function; ; in, and This represents the weight mapping parameters.
4. The method for enhancing the fault tolerance of a quantized neural network based on weight elastic mapping according to claim 3, characterized in that, Step S3 is as follows: By obtaining the weight perturbation elasticity, we can derive the range of weight parameters that maintain the model's accuracy. The weight mapping function expression is as follows: ; After obtaining the weight mapping parameters based on step S2, the weight mapping function expression is rewritten as follows: 。 5. The method for enhancing the fault tolerance of a quantized neural network based on weight elastic mapping according to claim 1, characterized in that, Step S4 is as follows: S41. Calculate the mapped weights based on the weight mapping function obtained in step S3; S42. Determine whether the mapping result is less than the maximum value of the quantization bit width range. If it is less, proceed to step S43. If it is greater, proceed to step S44. S43. The mapping result is truncated and rounded down as a weight parameter; S44. The maximum quantization bit width is used as a weighting parameter; S45. Based on the weight parameters obtained in steps S41-S44, perform inference to complete the fault tolerance enhancement.
