An automatic model reinforcement method based on neural network interpretability

By using an automatic model enhancement method based on neural network interpretability and combining reinforcement learning algorithms to optimize the redundancy ratio of convolutional kernels, the problem of fault impact on deep neural networks in complex environments is solved, achieving high efficiency in fault tolerance and robustness, and is applicable to various neural network architectures.

CN119761453BActive Publication Date: 2025-11-21NANJING UNIV OF AERONAUTICS & ASTRONAUTICS
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411215713.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-02
Publication Date
2025-11-21
Estimated Expiration
2044-09-02

AI Technical Summary

Technical Problem

Deep neural networks are susceptible to failures in complex environments, especially single-particle flips, burnouts, or lockouts caused by high-energy particles, which can lead to instruction flow errors and threaten program stability. Existing technologies struggle to achieve a good balance between system performance and robustness.

Method used

An automatic model reinforcement method based on neural network interpretability is adopted. By secondary development of PyTorchFI to simulate hardware failure, a Markov decision process is constructed by combining reinforcement learning algorithm, the importance of convolution kernel is calculated and redundancy reinforcement is performed to optimize the model's fault tolerance capability.

Benefits of technology

It improves the model's fault tolerance and robustness, reduces time and space overhead, is applicable to various neural network architectures, achieves high fault detection rate and low time and space overhead, and has good scalability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119761453B_ABST
    Figure CN119761453B_ABST
Patent Text Reader

Abstract

The application discloses an automatic model reinforcement method based on neural network interpretability. The method comprises the following steps: developing PytorchFI again, injecting faults based on IEEE 754 standard, and building a fault test environment, developing a batch fault injection tool and a redundancy reinforcement tool for model weights; constructing a model based on reinforcement learning, designing a standard Markov decision process for interaction between an agent and a neural network model, including state space, action space and reward function and the like; using SAC algorithm as a neural network architecture search algorithm to explore the redundancy ratio of in-layer convolution kernels; calculating the importance of the convolution kernels and sorting them based on the neuron integral gradient method; combining the SAC algorithm and the neural network interpretability to design an automatic model reinforcement framework, and redundantly reinforcing important convolution kernels. The application realizes model reinforcement based on neural network interpretability, can accurately identify the importance and redundancy demand of the convolution kernels, improves the fault tolerance and robustness of the model, has a higher fault detection rate and a lower space-time overhead, and is suitable for various convolutional neural network architectures.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of model-level SDC error detection and hardening technology, and in particular, it is an automatic model strengthening method based on neural network interpretability. Background Technology

[0002] Deep neural networks (DNNs) have become the preferred choice for most machine learning applications due to their state-of-the-art accuracy across a wide range of real-world applications, from simple handwritten digit recognition to complex safety-critical applications such as autonomous driving and drone collaboration. Typically, deep neural networks require a large set of parameters to achieve good generalization in real-time scenarios. To efficiently process data, dedicated hardware accelerators built using smaller technology nodes have been employed to improve power and performance efficiency.

[0003] A major challenge facing DNN accelerators in complex environments is their reliability against failures—specifically, failures caused by soft errors, aging, and manufacturing defects—which can have catastrophic consequences in safety-critical applications. Deep neural network applications are particularly vulnerable to model parameter errors. Even small random noise faults, such as single-event perturbations (SEUs) caused by ionized particles, can severely damage bit-flipping faults and weight matrix perturbations in DNNs. Furthermore, fault injection attacks and the high failure rates of emerging memory technologies like memristors further exacerbate the reliability issues of DNN applications. Ensuring the security of deep neural networks is increasingly crucial as they are widely used in everyday life. In particular, improving the robustness of deep neural networks to complex environments requires continuously strengthening security measures to ensure robust operation across various scenarios to meet ever-growing application demands.

[0004] To achieve efficient inference in deep neural networks (DNNs), dedicated hardware accelerators or graphics processing units (GPUs) are required. In complex environments and critical areas with severe radiation effects, high-energy particles can cause single-event upsets, burnouts, or lock-ups in processors, resulting in instruction flow errors that may lead to program crashes or system paralysis. Transient effects such as single-event upsets (SEUs) can also cause software errors, flipping bits in control logic and memory, potentially leading to silent data corruption (SDC) and causing outputs to deviate from expected detection results. Experiments have shown that the accuracy of deep learning-based classification algorithms can significantly decrease due to the impact of soft errors.

[0005] To mitigate the risk of transient failures, spaceborne equipment typically employs information redundancy techniques such as triple modular redundancy (TMR), at the cost of increased design complexity. In deep learning algorithms, selectively reinforcing DNN models has become a viable option. This method provides fine-grained, module-level redundancy, achieving a balance between system performance and robustness. However, current work primarily focuses on protecting weight bits, which remains a complex task for neural networks with billions of parameters. Therefore, achieving a good balance between system robustness and protection benefits through redundancy at the convolutional kernel level is a promising approach.

[0006] In summary, the widespread application of deep neural networks (DNNs) makes ensuring their efficient inference and security a crucial task. In critical fields such as aerospace, complex environments and radiation effects can lead to hardware failures, such as single-event flips, burnouts, or lockouts caused by high-energy particles, potentially triggering instruction flow errors and threatening program stability. A balance between system performance and robustness can be achieved through module-level redundancy. Current research mainly focuses on protecting weights, but this remains a complex task for neural networks with billions of parameters. Redundancy is implemented using convolutional kernels as the smallest unit. This strategy allows for a good balance between system robustness and protection benefits, providing a more feasible solution for the reliable operation of deep neural networks in complex environments. It also helps reduce the harm of failures to computer systems, which is of great significance for system security and reliability. Summary of the Invention

[0007] The purpose of this invention is to address the problems existing in the prior art by providing an automatic model reinforcement method based on neural network interpretability. This method achieves more efficient model fault tolerance and robustness by explicitly considering network layer information and combining reinforcement learning algorithms for model optimization, thereby improving the model's fault tolerance while reducing time and space overhead. Furthermore, this invention has good scalability and is applicable to various neural network architectures.

[0008] The technical solution to achieve the objective of this invention is as follows: On the one hand, an automatic model enhancement method based on neural network interpretability is provided, the method comprising the following steps:

[0009] Step 1: Perform secondary development on PyTorchFI to simulate hardware failures and build a failure testing environment;

[0010] Step 2: Develop a batch fault injection tool for model weights to simultaneously inject faults into multiple weights in the model for testing the model's fault tolerance and establishing a fault tolerance testing environment; at the same time, develop a convolution kernel redundancy hardening tool to enhance the model's fault tolerance through redundancy hardening and automate the model's fault tolerance mechanism.

[0011] Step 3: Construct a reinforcement learning model based on the reinforcement learning algorithm, and design a standard Markov decision process for the interaction between the agent and the neural network model;

[0012] Step 4: Train and optimize the reinforcement learning SAC algorithm to explore and predict the redundancy ratio of convolutional kernels in each layer of the neural network, and determine the optimal convolutional kernel redundancy ratio.

[0013] Step 5: Based on the neuron integral gradient method, calculate the importance score of each convolutional kernel, and sort the convolutional kernels in descending order according to the scores, and identify the convolutional kernels that have the greatest impact on model performance as key convolutional kernels.

[0014] Step 6: Combining the reinforcement learning SAC algorithm and the principle of neural network interpretability, design an automatic model reinforcement framework to redundancy-strengthen the convolutional kernels.

[0015] On the other hand, an automatic model enhancement system based on neural network interpretability is provided, the system comprising:

[0016] The first module is used for secondary development of PyTorchFI to simulate hardware failures and build a failure testing environment.

[0017] The second module is used to develop a batch fault injection tool for model weights, which can simultaneously inject faults into multiple weights in the model for testing the model's fault tolerance and establishing a fault tolerance testing environment. At the same time, a convolution kernel redundancy hardening tool is developed to enhance the model's fault tolerance through redundancy hardening and to automate the model's fault tolerance mechanism.

[0018] The third module is used to build a reinforcement learning model based on reinforcement learning algorithms and design a standard Markov decision process for the interaction between the agent and the neural network model.

[0019] The fourth module is used to train and optimize the reinforcement learning SAC algorithm to explore and predict the redundancy ratio of convolutional kernels in each layer of the neural network, and determine the optimal convolutional kernel redundancy ratio.

[0020] The fifth module is used to calculate the importance score of each convolutional kernel based on the neuron integral gradient method, and to sort the convolutional kernels in descending order according to the scores, and identify the convolutional kernels that have the greatest impact on model performance as key convolutional kernels.

[0021] The sixth module is used to design an automatic model reinforcement framework by combining the reinforcement learning SAC algorithm and the principle of neural network interpretability, and to redundancy-strengthen the convolutional kernel.

[0022] Compared with the prior art, the significant advantages of this invention are:

[0023] 1) Based on the interpretability of neural networks, the method explicitly considers the internal structural information of the model, thereby improving fault tolerance and robustness.

[0024] 2) Combining reinforcement learning algorithms, the SAC algorithm is used to optimize the model, explore the redundancy ratio of convolutional kernels, improve the fault detection rate and reduce time and space overhead.

[0025] 3) A flexible redundancy reinforcement mechanism provides granular configurable redundancy for key convolutional kernels, achieving high efficiency in fault tolerance and economic benefits.

[0026] 4) Achieves high fault detection rate and low time and space overhead, suitable for various neural network architectures.

[0027] 5) It has good scalability, is suitable for a variety of application scenarios, and can effectively achieve the purpose of high-precision detection of SDC errors at the model level and hardening the model redundancy.

[0028] The present invention will now be described in further detail with reference to the accompanying drawings. Attached Figure Description

[0029] Figure 1 This is a flowchart of the automatic model enhancement method based on neural network interpretability of the present invention.

[0030] Figure 2 This is a schematic diagram of an automatic model enhancement framework in one embodiment.

[0031] Figure 3 This is a performance loss diagram of different model redundancy hardening methods in one embodiment, including the initial model, redundancy hardening with uniform ratio in each layer, hardening with redundancy ratio manually set according to experience, and a comparison of the protection effect of the method of the present invention. Detailed Implementation

[0032] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0033] It should be noted that if the embodiments of the present invention involve descriptions such as "first" and "second," these descriptions are for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined with "first" and "second" may explicitly or implicitly include at least one of those features. Furthermore, the technical solutions of the various embodiments can be combined with each other, but this must be based on the ability of those skilled in the art to implement them. When the combination of technical solutions is contradictory or impossible to implement, it should be considered that such a combination of technical solutions does not exist and is not within the scope of protection claimed by the present invention.

[0034] In one embodiment, combined Figure 1 This paper provides an automatic model enhancement method based on neural network interpretability, the method comprising the following steps:

[0035] Step 1: Perform secondary development on PyTorchFI to simulate hardware failures and build a failure testing environment;

[0036] Step 2: Develop a batch fault injection tool for model weights to simultaneously inject faults into multiple weights in the model for testing the model's fault tolerance and establishing a fault tolerance testing environment; at the same time, develop a convolution kernel redundancy hardening tool to enhance the model's fault tolerance through redundancy hardening and automate the model's fault tolerance mechanism.

[0037] Step 3: Construct a reinforcement learning model based on the reinforcement learning algorithm, and design a standard Markov decision process for the interaction between the agent and the neural network model;

[0038] Step 4: Train and optimize the reinforcement learning SAC algorithm to explore and predict the redundancy ratio of convolutional kernels in each layer of the neural network, and determine the optimal convolutional kernel redundancy ratio.

[0039] Step 5: Based on the neuron integral gradient method, calculate the importance score of each convolutional kernel, and sort the convolutional kernels in descending order according to the scores, and identify the convolutional kernels that have the greatest impact on model performance as key convolutional kernels.

[0040] Step 6: Combining the reinforcement learning SAC algorithm and the principle of neural network interpretability, design an automatic model reinforcement framework to redundancy-strengthen the convolutional kernels.

[0041] Furthermore, in one embodiment, the secondary development of PyTorchFI described in step 1 includes: flipping the model weights based on the IEEE binary floating-point arithmetic standard to simulate hardware failure.

[0042] The secondary development of PyTorchFI specifically includes:

[0043] Step 1-1: Convert the weight values ​​to the binary representation of the IEEE 754 standard:

[0044] binary_representation = S w E w M w

[0045] Among them, S w For the sign bit, E w M is the exponent.w The last digit;

[0046] Step 1-2: Randomly select a bit p and flip it:

[0047] b′ p =1-b p

[0048] Where p is a randomly selected position, b p Let b′ be the original value of the p-th bit. p This is the value after flipping;

[0049] Steps 1-3: Construct a new binary representation and convert it back to a floating-point number w′:

[0050] w′=binary-to_float(b0b1...b p-1 b′ p b p+1 ...b m )

[0051] Where binary_to_float means converting the binary representation back to a floating-point number, and m+1 means the number of bits in the binary representation binary_representation.

[0052] Furthermore, in one embodiment, the standard Markov decision process for the agent-neural network model interaction described in step 3 is represented by a quintuple: (S, A, P) a R a , where S is the state space, representing the feedback perceived by the agent from the environment; A is the action space, representing a finite set of actions that the agent can perform; P a R is the state transition probability matrix, describing the probability of transitioning from one state to another; a γ is the reward function, which defines the learning objective of the agent; γ∈[0,1] is the reward discount factor, used to weigh the impact of future rewards.

[0053] In some embodiments, the standard Markov decision process for designing the interaction between the agent and the neural network model described in step 3 specifically includes:

[0054] Step 3-1, define the state space in each convolutional layer L i Define the following state space s i :

[0055] (i,N,C,H,W,S,K,F i F used F rest a i-1 P)

[0056] Where i represents the index of the network layer currently being processed; N represents the batch size, i.e., the number of samples processed in one forward propagation; C represents the number of channels in the input feature map; H and W represent the height and width of the input feature map, respectively; K is the size of the convolution kernel; S is the stride of the convolution operation; F i F represents the computational cost of the i-th layer, expressed in FLOPs; used F represents the total computational cost of the convolution kernels selected in the previous layers. rest This represents the number of FLOPs allowed for the remaining layers based on the total computational budget; a i-1 It is L i-1 The action taken by the layer, where P represents the number of weight parameters of the current convolutional layer;

[0057] Step 3-2, define the action space. The agent's action is to predict the proportion of sensitive convolutional kernels in each layer in order to perform TMR (triple redundancy) backup in each layer.

[0058] Define a continuous action space a t The region ∈ [0, 1] is used to achieve fine-tuning of redundant convolution kernels; and further constraints are imposed at each step to ensure that the action sequence meets the constraint of the target redundancy ratio α. Specifically, a minimum redundancy ratio α is defined for each layer. min When it is expected that even if the minimum redundancy ratio a is applied to all remaining layers, min If the computational budget is exceeded, the action 'a' of the current layer will be truncated. t Simultaneously, a dynamic minimum redundancy ratio function δ(t) is introduced. This function is adjusted based on the characteristics of the current layer or other factors and is not a fixed value. The above strategy is described by the following formula:

[0059]

[0060] In the formula, F all It is the total FLOPs of all layers, F allow It is the total FLOPs of the current layer, F follw It is the total FLOPs of the remaining layers, L t Let F represent the τth layer. i This represents the computational cost of the t-th layer;

[0061] Step 3-3, define the following reward function R. acc Used to comprehensively consider average performance and worst-case performance:

[0062] R err =μ·acccuracy average +(1-μ)acccuracy min

[0063] Among them, accuracyaverage Accuracy represents the average accuracy rate. min denoted by , where μ represents the minimum accuracy and μ represents the weight.

[0064] Furthermore, in one embodiment, step 4, which involves training and optimizing the reinforcement learning SAC algorithm to explore and predict the redundancy ratio of convolutional kernels in each layer of the neural network, specifically includes:

[0065] Step 4-1, Initialize the neural network;

[0066] Step 4-2: Optimize the policy network (Actor) and value network (Critic) by repeatedly training the reinforcement learning SAC algorithm.

[0067] Step 4-3: Use the reinforcement learning SAC algorithm trained and optimized in step 4-2 to search for neural network architecture and dynamically adjust the redundancy ratio of each convolutional kernel.

[0068] In some embodiments, the initialization of the neural network in step 4-1 specifically includes:

[0069] Two Critic networks Q are initialized with random network parameters W1, w2, and θ, respectively. w1 (s, a), Q w2 (s, a) and Actor network π θ (s);

[0070] Copy the same parameters w′1←w1 and w′2←w2 to initialize two target Critic networks respectively. and

[0071] Initialize the experience replay pool R.

[0072] In some embodiments, step 4-2 is implemented through a three-layer nested loop: the outermost layer is the sequence loop of step 4-2-1, ensuring multiple complete interactions with the environment; the middle layer is the time-step loop of step 4-2-1-1, handling the decision and environment response at each time step; the innermost layer is the training sample update loop of step 4-2-1-1-1, which improves the policy performance by optimizing network parameters; specifically including:

[0073] Set the sequence loop count E, the time step loop count T, and the training round count K;

[0074] Step 4-2-1: The sequence loops from 1 to E, with the outermost loop running E times. Each sequence loop represents a complete interaction cycle. Starting from the initial state s1 of the environment, a new sequence begins until the preset termination condition is met. In each sequence, a series of experience samples are collected for subsequent learning.

[0075] Step 4-2-1—1, the time step loop runs from 1 to T, and at each time step within each sequence, the following is executed:

[0076] (1) Randomly select action a according to the current strategy. t =π θ (s t ), where s t This indicates the environmental state corresponding to the current time step t;

[0077] (2) Execute action a t Receive reward r t The environmental state becomes s t+1 .

[0078] (3) (s) t a t r t s t+1 Store in playback pool R;

[0079] Step 4-2-1-1-1, the training rounds cycle from 1 to K, execute:

[0080] (1) Sample N tuples {(s) from R. i a i r i s i+1 )} i=1,...,N ;

[0081] (2) For each tuple, compute using the target network. Where r i Indicates the environment execution action a at the current time step i. i Instant reward, γ is a discount factor, between 0 and 1; Indicates the next state s i+1 and a i+1 Below, the minimum value of two different value networks; π θ (a i+1 |s i+1 ) represents the state s given by the state s i+1 Under the condition of π, the policy network θ The generated action probability distribution, where θ is a parameter of the policy network; alogπ θ (a i+1 |s i+1 ) represents the entropy term of the strategy, α is the entropy coefficient used to balance the exploration and exploitation of the strategy, logπ θ (a i+1 |s i+1 ) represents the policy network π θ In state s i+1 Choose action ai+1 The logarithm of the probability.

[0082] (3) Perform the following updates on the two Critic networks respectively: For j=1,2, minimize the loss function.

[0083] (4) Using the reparameter technique to sample a θ (s i Then update the current Actor network with the following loss:

[0084] (5) Update the entropy coefficient α;

[0085] (6) Update the target network: w′1←τw1+(1-τ)w′1,w′2←τw2+(1-τ)w′2,τ is the soft update coefficient, which is used to control the degree of influence of the main network parameters on the update of the target network.

[0086]

[0087]

[0088] Furthermore, in one embodiment, step 5 utilizes neural network interpretability to calculate the importance score of the convolution kernel based on the neuron integral gradient method, specifically including:

[0089] Step 5-1: Calculate the importance score of each neuron in the convolutional layer using the neuron integral gradient method. The calculation formula is as follows:

[0090]

[0091] In the formula, Cond y (x) represents the importance score of a neuron y given input x; x′ is the baseline input, representing a neutral or reference input; x is the actual input, used to calculate the importance of neuron y under this input; ρ is the integration variable, taking values ​​in the range [0, 1], used for linear interpolation between input x′ and actual input x; y(ρ) represents the value of neuron y under the interpolation parameter ρ. As ρ changes from 0 to 1, the state of the neuron gradually changes from the value corresponding to the baseline input to the value corresponding to the actual input; F(x′+ρ(xx′)) represents the value of the neural network output function F under the current input x′+ρ(xx′), where x′+ρ(xx′) represents an interpolation that gradually transitions from x′ to the actual input x; The output function F represents the partial derivative of the neuron y(ρ), and represents the rate of change of F when the neuron y(ρ) changes. y is the rate of change of neuron y relative to the interpolation parameter ρ, indicating how neuron ρ changes as ρ changes; dρ is the differential element, representing the increment when integrating with respect to ρ;

[0092] Specifically, it accumulates the influence of neuron y(ρ) on output F throughout the transition, thus deriving the importance of neuron y for a given input x.

[0093] Step 5-2: Calculate the importance of neurons in the convolutional layer;

[0094] Let the output of the convolutional layer be A, with dimensions (N, C, H, W), where N is the batch size, C is the number of channels (i.e., the number of convolutional kernels), H is the feature map height, and W is the feature map width. For each neuron in the convolutional layer, calculate the importance of each output neuron using the method in step 5-1 and store it in tensor A. attributions middle:

[0095] Attributions N,C,H,W =Cond N,C,H,W (x)

[0096] In the formula, Attributions N,C,H,W This represents the importance of the neuron at position H and width W in channel C of the Nth sample. N,C,H,W (x) represents the importance of the neuron at position (H, W) in channel C for the Nth sample corresponding to input x;

[0097] Step 5-3: Calculate the importance of the convolution kernel. Since the convolution kernel affects all locations in the entire feature map, to quantify its global contribution, the importance scores of all neurons within a channel are summed. Specifically, by averaging the neuron importance scores across the feature map's height and width, a value representing the average influence of the convolution kernel on the entire input feature map can be obtained. The calculation formula is:

[0098]

[0099] This means averaging the importance scores of all H×W neurons in each channel C.

[0100] Furthermore, in one embodiment, step 6 combines the SAC algorithm and neural network interpretability to design an automatic model reinforcement framework, such as... Figure 2 As shown, redundancy hardening is applied to important convolutional kernels, specifically including:

[0101] Step 6-1: Based on the approach in Step 3, the process of interaction between the SAC agent and the neural network model is designed as a standard Markov decision process.

[0102] Step 6-2: For each layer, use the reinforcement learning SAC algorithm from step 4 to perform a layer-by-layer search and predict the proportion of key convolutional kernels in the current layer.

[0103] Step 6-3: Calculate and sort the importance of the convolutional kernels in the current layer using the method in step 5, and locate the positions of the key convolutional kernels;

[0104] Step 6-4: Use the convolution kernel redundancy hardening tool in Step 2 to redundancy harden the key convolution kernels of the current layer. Then send the model to the fault test environment established in Step 1. Use the fault tolerance test results as a reward to incentivize the agent to update the strategy and immediately search and optimize the next layer.

[0105] Step 6-5: After all layers have been traversed, the convolution kernel redundancy hardening tool from Step 2 is used again to perform TMR backup on the key convolution kernels updated during the traversal.

[0106] In one embodiment, an automatic model reinforcement system based on neural network interpretability is proposed, the system comprising:

[0107] The first module is used for secondary development of PyTorchFI to simulate hardware failures and build a failure testing environment.

[0108] The second module is used to develop a batch fault injection tool for model weights, which can simultaneously inject faults into multiple weights in the model for testing the model's fault tolerance and establishing a fault tolerance testing environment. At the same time, a convolution kernel redundancy hardening tool is developed to enhance the model's fault tolerance through redundancy hardening and to automate the model's fault tolerance mechanism.

[0109] The third module is used to build a reinforcement learning model based on reinforcement learning algorithms and design a standard Markov decision process for the interaction between the agent and the neural network model.

[0110] The fourth module is used to train and optimize the reinforcement learning SAC algorithm to explore and predict the redundancy ratio of convolutional kernels in each layer of the neural network, and determine the optimal convolutional kernel redundancy ratio.

[0111] The fifth module is used to calculate the importance score of each convolutional kernel based on the neuron integral gradient method, and to sort the convolutional kernels in descending order according to the scores, and identify the convolutional kernels that have the greatest impact on model performance as key convolutional kernels.

[0112] The sixth module is used to design an automatic model reinforcement framework by combining the reinforcement learning SAC algorithm and the principle of neural network interpretability, and to redundancy-strengthen the convolutional kernel.

[0113] Specific limitations regarding the automatic model enhancement system based on neural network interpretability can be found in the limitations of the automatic model enhancement method based on neural network interpretability mentioned above, and will not be repeated here. Each module in the aforementioned automatic model enhancement system based on neural network interpretability can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the corresponding operations of each module.

[0114] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements:

[0115] Step 1: Perform secondary development on PyTorchFI to simulate hardware failures and build a failure testing environment;

[0116] Step 2: Develop a batch fault injection tool for model weights to simultaneously inject faults into multiple weights in the model for testing the model's fault tolerance and establishing a fault tolerance testing environment; at the same time, develop a convolution kernel redundancy hardening tool to enhance the model's fault tolerance through redundancy hardening and automate the model's fault tolerance mechanism.

[0117] Step 3: Construct a reinforcement learning model based on the reinforcement learning algorithm, and design a standard Markov decision process for the interaction between the agent and the neural network model;

[0118] Step 4: Train and optimize the reinforcement learning SAC algorithm to explore and predict the redundancy ratio of convolutional kernels in each layer of the neural network, and determine the optimal convolutional kernel redundancy ratio.

[0119] Step 5: Based on the neuron integral gradient method, calculate the importance score of each convolutional kernel, and sort the convolutional kernels in descending order according to the scores, and identify the convolutional kernels that have the greatest impact on model performance as key convolutional kernels.

[0120] Step 6: Combining the reinforcement learning SAC algorithm and the principle of neural network interpretability, design an automatic model reinforcement framework to redundancy-strengthen the convolutional kernels.

[0121] For specific limitations on each step, please refer to the limitations of the automatic model enhancement method based on neural network interpretability mentioned above, which will not be repeated here.

[0122] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program being implemented when executed by a processor:

[0123] Step 1: Perform secondary development on PyTorchFI to simulate hardware failures and build a failure testing environment;

[0124] Step 2: Develop a batch fault injection tool for model weights to simultaneously inject faults into multiple weights in the model for testing the model's fault tolerance and establishing a fault tolerance testing environment; at the same time, develop a convolution kernel redundancy hardening tool to enhance the model's fault tolerance through redundancy hardening and automate the model's fault tolerance mechanism.

[0125] Step 3: Construct a reinforcement learning model based on the reinforcement learning algorithm, and design a standard Markov decision process for the interaction between the agent and the neural network model;

[0126] Step 4: Train and optimize the reinforcement learning SAC algorithm to explore and predict the redundancy ratio of convolutional kernels in each layer of the neural network, and determine the optimal convolutional kernel redundancy ratio.

[0127] Step 5: Based on the neuron integral gradient method, calculate the importance score of each convolutional kernel, and sort the convolutional kernels in descending order according to the scores, and identify the convolutional kernels that have the greatest impact on model performance as key convolutional kernels.

[0128] Step 6: Combining the reinforcement learning SAC algorithm and the principle of neural network interpretability, design an automatic model reinforcement framework to redundancy-strengthen the convolutional kernels.

[0129] For specific limitations on each step, please refer to the limitations of the automatic model enhancement method based on neural network interpretability mentioned above, which will not be repeated here.

[0130] As a specific example, the invention will be further verified and illustrated in one embodiment.

[0131] Figure 3 This paper presents a comparison of performance losses under different model redundancy hardening methods, including the initial model, redundancy hardening with uniform proportions across all layers, hardening with manually set redundancy proportions based on experience, and the protection effect of the present invention's convolutional neural network redundancy hardening framework (AMHR) based on neural network interpretability. The horizontal axis represents the number of fault injections, and the vertical axis represents the accuracy (%).

[0132] In the experiment, the SAC algorithm was selected for model reinforcement training. VGG16 was used as the base network, and the target redundancy α was set to 0.3 and the minimum redundancy a0 was set to 0.3. min The value is 0.1. Environment setup includes loading the correct model weights and the parameters of the faulty model. Then, PyTorchFI is used for fault injection to simulate bit-flipping errors in real-world applications.

[0133] The initial model, without redundancy protection, experiences a rapid decline in accuracy with increasing fault injections. After 600 fault injections, the accuracy drops to nearly 20%. This is because the model is highly sensitive to faults due to the lack of redundancy protection. Uniform redundancy hardening across layers offers some improvement over the initial model. After 600 fault injections, the accuracy is approximately 40%. This method improves the model's fault tolerance by uniformly increasing redundancy across all layers, but the effect is limited because it fails to differentiate the importance of different layers. Handcrafted redundancy hardening, based on experience, outperforms uniform redundancy hardening, achieving approximately 50% accuracy after 600 fault injections. This method relies on experience, setting different redundancy ratios based on the importance of different layers, thus improving the model's fault tolerance to some extent, but it is still not ideal. The AMHR (Ambivalent Convolutional Neural Network Redundancy Hardening) framework, based on neural network interpretability, performs best, maintaining an accuracy close to 60% after 600 fault injections. This method significantly improves the model's fault tolerance and robustness by calculating the importance of convolutional kernels in the neural network and performing targeted redundancy hardening. This demonstrates that redundancy hardening strategies based on neural network interpretability can more effectively protect the model.

[0134] As shown above, the AMHR (Ambivalent Advanced Hardening) method based on neural network interpretability exhibits the highest fault tolerance and lowest performance loss when facing fault injection, demonstrating a significant advantage over other methods. By selectively hardening important convolutional kernels, the AMHR method can more effectively improve the robustness of the model, thereby maintaining high accuracy in high-fault environments. This further validates the potential application value of neural network interpretability in model optimization.

[0135] In summary, the model optimization method proposed in this invention, based on neural network interpretability and reinforcement learning, selectively chooses important convolutional kernels through neural network interpretability algorithms, providing interpretable options for model redundancy hardening. Combining the SAC algorithm for model optimization explores the redundancy ratio of convolutional kernels, improving fault detection rate and reducing time and space overhead. Simultaneously, the flexible redundancy hardening mechanism allows for granularly configurable redundancy of important convolutional kernels, achieving a balance between high efficiency and cost-effectiveness. Comparison with other related algorithms further verifies that this invention can more efficiently perform fault detection and hardening in various neural network architectures and application scenarios, effectively achieving high-precision SDC error detection and redundancy hardening at the model level.

[0136] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The embodiments and descriptions in the specification are merely illustrative of the principles of the invention. Various changes and modifications can be made to the invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of the claimed invention.

Claims

1. An automatic model enhancement method based on neural network interpretability, characterized in that, The method includes the following steps: Step 1: Perform secondary development on PyTorchFI to simulate hardware failures and build a failure testing environment; Step 2: Develop a batch fault injection tool for model weights to simultaneously inject faults into multiple weights in the model for testing the model's fault tolerance and establishing a fault tolerance testing environment; at the same time, develop a convolution kernel redundancy hardening tool to enhance the model's fault tolerance through redundancy hardening and automate the model's fault tolerance mechanism. Step 3: Construct a reinforcement learning model based on the reinforcement learning algorithm, and design a standard Markov decision process for the interaction between the agent and the neural network model; Step 4: Train and optimize the reinforcement learning SAC algorithm to explore and predict the redundancy ratio of convolutional kernels in each layer of the neural network, and determine the optimal convolutional kernel redundancy ratio. Step 5: Based on the neuron integral gradient method, calculate the importance score of each convolutional kernel, and sort the convolutional kernels in descending order according to the scores, and identify the convolutional kernels that have the greatest impact on model performance as key convolutional kernels. Step 6: Combining the reinforcement learning SAC algorithm and the principle of neural network interpretability, design an automatic model reinforcement framework to redundancy-strengthen the convolutional kernels; specifically including: Step 6-1: Based on the approach in Step 3, the process of interaction between the SAC agent and the neural network model is designed as a standard Markov decision process. Step 6-2: For each layer, use the reinforcement learning SAC algorithm from step 4 to perform a layer-by-layer search and predict the proportion of key convolutional kernels in the current layer. Step 6-3: Calculate and sort the importance of the convolutional kernels in the current layer using the method in step 5, and locate the positions of the key convolutional kernels; Step 6-4: Use the convolution kernel redundancy hardening tool in Step 2 to redundancy harden the key convolution kernels of the current layer. Then send the model to the fault test environment established in Step 1. Use the fault tolerance test results as a reward to incentivize the agent to update the strategy and immediately search and optimize the next layer. Step 6-5: After all layers have been traversed, the convolution kernel redundancy hardening tool from Step 2 is used again to perform TMR backup on the key convolution kernels updated during the traversal.

2. The automatic model enhancement method based on neural network interpretability according to claim 1, characterized in that, The secondary development of PyTorchFI described in step 1 includes: flipping the model weights based on the IEEE binary floating-point arithmetic standard to simulate hardware failures.

3. The automatic model enhancement method based on neural network interpretability according to claim 2, characterized in that, The secondary development of PyTorchFI specifically includes: Step 1-1: Convert the weight values ​​to the binary representation of the IEEE 754 standard: binary_representation=S w E w M w Among them, S w For the sign bit, E w M is the exponent. w The last digit; Step 1-2: Randomly select a bit p and flip it: b' p =1-b p Where p is a randomly selected position, b p b' is the original value of the p-th bit. p This is the value after flipping; Steps 1-3: Construct a new binary representation and convert it back to a floating-point number w': w'=binary_to_float(b0b1…b p-1 b' p b p+1 …b m ) Where binary_to_float means converting the binary representation back to a floating-point number, and m+1 means the number of bits in the binary representation binary_representation.

4. The automatic model enhancement method based on neural network interpretability according to claim 1, characterized in that, The standard Markov decision process for the agent-neural network model interaction described in step 3 is represented by a quintuple: (S, A, P) a ,R a ,γ), where S is the state space, representing the feedback perceived by the agent from the environment; A is the action space, representing a finite set of actions that the agent can perform; P a R is the state transition probability matrix, describing the probability of transitioning from one state to another; a γ is the reward function, which defines the learning objective of the agent; γ∈[0,1] is the reward discount factor, used to weigh the impact of future rewards.

5. The automatic model enhancement method based on neural network interpretability according to claim 4, characterized in that, Step 3, which describes the design of a standard Markov decision process for the interaction between the agent and the neural network model, specifically includes: Step 3-1, define the state space in each convolutional layer L i Define the following state space s i : (i,N,C,H,W,S,K,F i ,F used ,F rest ,a i-1 ,P) Where i represents the index of the network layer currently being processed; N represents the batch size, i.e., the number of samples processed in one forward propagation; C represents the number of channels in the input feature map; H and W represent the height and width of the input feature map, respectively; K is the size of the convolution kernel; S is the stride of the convolution operation; F i F represents the computational cost of the i-th layer, expressed in FLOPs; used F represents the total computational cost of the convolution kernels selected in the previous layers. rest This represents the number of FLOPs allowed for the remaining layers based on the total computational budget; a i-1 It is L i-1 The action taken by the layer, where P represents the number of weight parameters of the current convolutional layer; Step 3-2, define the action space. The agent's action is to predict the proportion of sensitive convolutional kernels in each layer in order to perform TMR backup in each layer; Define a continuous action space a t The region ∈[0,1] is used to achieve fine-tuning of redundant convolution kernels; and further constraints are imposed at each step to ensure that the action sequence meets the constraint of the target redundancy ratio α. Specifically, a minimum redundancy ratio α is defined for each layer. min When it is expected that even if the minimum redundancy ratio a is applied to all remaining layers, min If the computational budget is exceeded, the action 'a' of the current layer will be truncated. t Simultaneously, a dynamic minimum redundancy ratio function δ(t) is introduced. This function is adjusted based on the characteristics of the current layer or other factors and is not a fixed value; it is described by the following formula: In the formula, F all It is the total FLOPs of all layers, F allow It is the total FLOPs of the current layer, F follw It is the total FLOPs of the remaining layers, L t Let F represent the t-th layer. i This represents the computational cost of the t-th layer; Step 3-3, define the following reward function R. acc Used to comprehensively consider average performance and worst-case performance: R err =μ·acccuracy average +(1-μ)acccuracy min Among them, accuracy average Accuracy represents the average accuracy rate. min denoted by , where μ represents the minimum accuracy and μ represents the weight.

6. The automatic model enhancement method based on neural network interpretability according to claim 4, characterized in that, Step 4, which describes training and optimizing the reinforcement learning SAC algorithm to explore and predict the redundancy ratio of convolutional kernels in each layer of the neural network, specifically includes: Step 4-1, Initialize the neural network; Step 4-2: Optimize the policy network (Actor) and value network (Critic) by repeatedly training the reinforcement learning SAC algorithm. Step 4-3: Use the reinforcement learning SAC algorithm trained and optimized in step 4-2 to search for neural network architecture and dynamically adjust the redundancy ratio of each convolutional kernel.

7. The automatic model enhancement method based on neural network interpretability according to claim 6, characterized in that, Step 4-1, which initializes the neural network, specifically includes: Two Critic networks Q are initialized with random network parameters w1, w2, and θ, respectively. w1 (s,a), Q w2 (s,a) and Actor network π θ (s); Copy the same parameters w'1←w1 and w'2←w2 to initialize two target Critic networks respectively. and Initialize the experience replay pool R.

8. The automatic model enhancement method based on neural network interpretability according to claim 6, characterized in that, Step 4-2 is implemented through a three-layer nested loop: the outermost layer is the sequence loop of step 4-2-1, which ensures multiple complete interactions with the environment; the middle layer is the time step loop of step 4-2-1-1, which handles the decision and environment response at each time step; and the innermost layer is the training sample update loop of step 4-2-1-1-1, which improves the performance of the policy by optimizing the network parameters. Specifically, it includes: Set the sequence loop count E, the time step loop count T, and the training round count K; Step 4-2-1: The sequence loops from 1 to E, with the outermost loop running E times. Each sequence loop represents a complete interaction cycle. Starting from the initial state s1 of the environment, a new sequence begins until the preset termination condition is met. In each sequence, a series of experience samples are collected for subsequent learning. Step 4-2-1-1, the time step loop runs from 1 to T, and at each time step within each sequence, the following is executed: (1) Randomly select action a according to the current strategy. t =π θ (s t ), where s t This indicates the environmental state corresponding to the current time step t; (2) Execute action a t Receive reward r t The environmental state becomes s t+1 ; (3) (s) t ,a t ,r t ,s t+1 Store in playback pool R; Step 4-2-1-1-1, the training rounds cycle from 1 to K, execute: (1) Sample N tuples {(s) from R. i ,a i ,r i ,s i+1 )} i=1,…,N ; (2) For each tuple, compute using the target network. Where r i Indicates the environment execution action a at the current time step i. i Instant reward, γ is a discount factor, between 0 and 1; Indicates the next state s i+1 and a i+1 Below, the minimum value of two different value networks; π θ (a i+1 |s i+1 ) represents the state s given by the state s i+1 Under the condition of π, the policy network θ The generated action probability distribution, where θ is a parameter of the policy network; αlogπ θ (a i+1 |s i+1 ) represents the entropy term of the strategy, α is the entropy coefficient used to balance the exploration and exploitation of the strategy, logπ θ (a i+1 |s i+1 ) represents the policy network π θ In state s i+1 Choose action a i+1 The logarithm of the probability; (3) Perform the following updates on the two Critic networks respectively: For j=1,2, minimize the loss function. (4) Using the reparameter technique to sample a θ (s i Then update the current Actor network with the following loss: (5) Update the entropy coefficient α; (6) Update the target network: w'1←τw1+(1-τ)w'1, w'2←τw2+(1-τ)w'2, where τ is the soft update coefficient.

9. The automatic model enhancement method based on neural network interpretability according to claim 5, characterized in that, In step 5, leveraging the interpretability of neural networks, the importance score of the convolutional kernel is calculated based on the neuron integral gradient method, specifically including: Step 5-1: Calculate the importance score of each neuron in the convolutional layer using the neuron integral gradient method. The calculation formula is as follows: In the formula, Cond y (x) represents the importance score of a neuron y given input x; x' is the baseline input, representing a neutral or reference input; x is the actual input, used to calculate the importance of the corresponding neuron y under this input; ρ is the integration variable, taking values ​​in the range [0,1], used for linear interpolation between input x' and actual input x; y(ρ) represents the value of neuron y under the interpolation parameter ρ; F(x'+ρ(x-x')) represents the value of the neural network output function F under the current input x'+ρ(x-x'), and x'+ρ(x-x') represents an interpolation that gradually transitions from x' to the actual input x; Step 5-2: Calculate the importance of neurons in the convolutional layer; Let the output of the convolutional layer be A, with dimensions (N, C, H, W), where N is the batch size, C is the number of channels (i.e., the number of convolutional kernels), H is the feature map height, and W is the feature map width. For each neuron in the convolutional layer, calculate the importance of each output neuron using the method in step 5-1 and store it in tensor A. attributions middle: Attributions N,C,H,W =Cond N,C,H,W (x) In the formula, Attributions N,C,H,W This represents the importance of the neuron at position H and width W in channel C of the Nth sample. N,C,H,W (x) represents the importance of the neuron at position (H, W) in channel C for the Nth sample corresponding to input x; Step 5-3, calculate the importance of the convolution kernel, the formula is: This means averaging the importance scores of all H×W neurons in each channel C.

Citation Information

Patent Citations

  • Convolutional neural network fault injection system based on TensorFlow

    CN111563578A

  • Deep neural network generation method for reinforcement learning

    CN115511077A