Automatic model strengthening method based on interpretability of neural network
Through an automatic model reinforcement method based on neural network interpretability, combined with reinforcement learning algorithms and convolution kernel redundancy reinforcement technology, the hardware failure reliability problem faced by deep neural networks in complex environments is solved, and the robustness and fault tolerance of the model are significantly improved.
Patent Information
- Application Number
- CN202411215713.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-02
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2044-09-02
AI Technical Summary
Deep neural networks (DNNs) face reliability problems in complex environments and critical areas with severe radiation effects, resulting in model parameter errors and silent data corruption (SDC), affecting the robustness and security of the model.
Using an automatic model reinforcement method based on neural network interpretability, a fault testing environment is built by secondary development of PytorchFI, batch fault injection tools and convolution kernel redundancy reinforcement tools are developed, combined with reinforcement learning algorithms such as SAC, the redundancy ratio of the convolution kernel is optimized, the convolution kernel importance score is calculated, and an automatic model reinforcement framework is designed for redundancy reinforcement.
It significantly improves the fault tolerance and robustness of the model, realizes efficient fault detection and reinforcement, reduces space-time overhead, is suitable for a variety of neural network architectures, and has good scalability.
Smart Images

Figure CN119761453A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of model-level SDC error detection reinforcement, and in particular to an automatic model reinforcement method based on neural network interpretability. Background Art
[0002] Deep neural networks (DNNs) have become the first choice for most machine learning-based applications due to their state-of-the-art accuracy in various applications in life, ranging 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. In order to process data efficiently, dedicated hardware accelerators built using smaller technology nodes are used to improve power and performance efficiency.
[0003] A major issue facing DNN accelerators in complex environments is their reliability against faults, i.e., they suffer from failures caused by soft errors, aging, and manufacturing-induced defects, which can lead to catastrophic effects when used in safety-critical applications. Deep neural network applications are vulnerable to model parameter errors. Even small random noise faults, such as single event upsets (SEUs) caused by ionized particles, can cause serious damage to bit flip faults and weight matrix perturbations in DNNs. In addition, fault injection attacks and the high failure rate of emerging memory technologies such as memristors further exacerbate the reliability issues of DNN applications. With the widespread application of deep neural networks in daily life, it is increasingly important to ensure their security. In particular, in terms of improving the robustness of deep neural networks to complex environments, it is necessary to continuously strengthen security measures to ensure that the network can operate robustly in various scenarios to meet the growing application needs.
[0004] In order to achieve efficient reasoning of deep neural networks (DNNs), devices such as dedicated hardware accelerators or graphics processing units (GPUs) are required. In critical areas with complex environments and severe radiation effects, high-energy particles may cause single-particle flips, burns, or locks in the processor, resulting in instruction flow errors that may cause program crashes or system paralysis. Transient effects such as single event effects (SEUs) can also cause software errors, flipping bits in control logic and memory, which may eventually lead to silent data corruption (SDC), causing the output to deviate from the expected detection results. Experiments have shown that the accuracy of deep learning-based classification algorithms may drop significantly due to the influence of soft errors.
[0005] To reduce the risk of transient failures, onboard equipment often uses information redundancy techniques such as triple modular redundancy (TMR) at the expense of increased design complexity. In deep learning algorithms, selective reinforcement of DNN models has become a viable option. This approach provides fine-grained module-level redundancy and achieves a balance between system performance and robustness. However, current work mainly 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 by using convolution kernels as the smallest unit for redundancy has become a promising approach.
[0006] In summary, the widespread application of deep neural networks (DNNs) makes it a vital task to ensure their efficient reasoning and safety. In key areas such as aerospace, complex environments and radiation effects may cause hardware failures, such as single-particle upsets, burnouts, or lockups caused by high-energy particles, which may trigger instruction flow errors and threaten the stability of the program. A balance between system performance and robustness is achieved through module-level redundancy. Current research focuses on protecting weight bits, but this is still a complex task for neural networks with billions of parameters. Redundancy is performed with convolution kernels as the smallest unit. Through this strategy, a good balance between system robustness and protection benefits can be achieved, providing a more feasible solution for the reliable operation of deep neural networks in complex environments. It is conducive to reducing the harm of failures to computer systems and is of great significance to system security and reliability. Summary of the invention
[0007] The purpose of the present invention is to provide an automatic model reinforcement method based on neural network interpretability to address the problems existing in the above-mentioned prior art, achieve more efficient model fault tolerance and robustness, explicitly consider the model network layer information, and combine the reinforcement learning algorithm to optimize the model to improve the fault tolerance of the model while reducing the time and space overhead. In addition, the present invention has good scalability and is applicable to a variety of neural network architectures.
[0008] The technical solution to achieve the purpose of the present invention is: on the one hand, an automatic model enhancement method based on neural network interpretability is provided, and the method comprises the following steps:
[0009] Step 1: Perform secondary development on PytorchFI to simulate hardware failures and build a failure test environment;
[0010] Step 2: Develop a batch fault injection tool for model weights to inject faults into multiple weights in the model at the same time, which is used to test the model's fault tolerance and establish a fault-tolerant test environment. At the same time, develop a convolution kernel redundancy reinforcement tool to enhance the model's fault tolerance through redundant reinforcement and realize the automation of the model's fault tolerance mechanism.
[0011] Step 3: Build 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 convolution kernels in each layer of the neural network and determine the optimal redundancy ratio of convolution kernels;
[0013] Step 5: Based on the neuron integral gradient method, calculate the importance score of each convolution kernel, sort the convolution kernels in descending order according to the score, and identify the convolution kernel with the greatest impact on the model performance as the key convolution kernel;
[0014] Step 6: Combining the reinforcement learning SAC algorithm and the principle of neural network interpretability, an automatic model reinforcement framework is designed to perform redundant reinforcement on the convolution kernel.
[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 test environment;
[0017] The second module is used to develop a batch fault injection tool for model weights to inject faults into multiple weights in the model at the same time, which is used to test the model's fault tolerance and establish a fault-tolerant test environment. At the same time, a convolution kernel redundancy reinforcement tool is developed to enhance the model's fault tolerance through redundant reinforcement and realize the automation of the model's fault-tolerant mechanism.
[0018] The third module is used to build 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;
[0019] The fourth module is used to train and optimize the reinforcement learning SAC algorithm to explore and predict the redundancy ratio of convolution kernels in each layer of the neural network and determine the optimal redundancy ratio of convolution kernels;
[0020] The fifth module is used to calculate the importance score of each convolution kernel based on the neuron integral gradient method, and sort the convolution kernels in descending order according to the score, and identify the convolution kernel with the greatest impact on the model performance as the key convolution kernel;
[0021] The sixth module is used to combine the reinforcement learning SAC algorithm and the principle of neural network interpretability to design an automatic model reinforcement framework and perform redundant reinforcement on the convolution kernel.
[0022] Compared with the prior art, the present invention has the following significant advantages:
[0023] 1) Based on the neural network interpretability method, the internal structure information of the model is explicitly considered to improve fault tolerance and robustness.
[0024] 2) Combined with the reinforcement learning algorithm, the SAC algorithm is used to optimize the model, explore the redundancy ratio of the convolution kernel, improve the fault detection rate and reduce the time and space overhead.
[0025] 3) Flexible redundancy reinforcement mechanism, which provides granular configurable redundancy for key convolution kernels to achieve efficient fault tolerance and economic benefits.
[0026] 4) Achieve high fault detection rate and low space-time overhead, and be applicable to a variety of neural network architectures.
[0027] 5) It has good scalability and is suitable for a variety of application scenarios. It can effectively achieve the purpose of high-precision detection of SDC errors at the model level and reinforce model redundancy.
[0028] The present invention is further described in detail below in conjunction with the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 This is a flow chart of the automatic model enhancement method based on neural network interpretability of the present invention.
[0030] Figure 2 Schematic diagram of an automatic model enhancement framework in one embodiment.
[0031] Figure 3 It is a performance loss diagram under different model redundant reinforcement methods in an embodiment, including a comparison of the protection effects of the initial model, redundant reinforcement with a uniform ratio for each layer, reinforcement with a manually set redundant ratio based on experience, and reinforcement with the method of the present invention. DETAILED DESCRIPTION
[0032] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0033] It should be noted that if there are descriptions involving "first", "second", etc. in the embodiments of the present invention, the descriptions of "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such a combination of technical solutions does not exist and is not within the scope of protection required by the present invention.
[0034] In one embodiment, in combination Figure 1 , 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 test environment;
[0036] Step 2: Develop a batch fault injection tool for model weights to inject faults into multiple weights in the model at the same time, which is used to test the model's fault tolerance and establish a fault-tolerant test environment. At the same time, develop a convolution kernel redundancy reinforcement tool to enhance the model's fault tolerance through redundant reinforcement and realize the automation of the model's fault tolerance mechanism.
[0037] Step 3: Build 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 convolution kernels in each layer of the neural network and determine the optimal redundancy ratio of convolution kernels;
[0039] Step 5: Based on the neuron integral gradient method, calculate the importance score of each convolution kernel, sort the convolution kernels in descending order according to the score, and identify the convolution kernel with the greatest impact on the model performance as the key convolution kernel;
[0040] Step 6: Combining the reinforcement learning SAC algorithm and the principle of neural network interpretability, an automatic model reinforcement framework is designed to perform redundant reinforcement on the convolution kernel.
[0041] Furthermore, in one of the embodiments, 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.
[0042] The secondary development of PytorchFI specifically includes:
[0043] Step 1-1, convert the weight value into the binary representation of the IEEE 754 standard:
[0044] binary_representation=S w E w M w
[0045] Among them, S w is the sign bit, E w is the exponent bit, Mw is the last digit;
[0046] Step 1-2, randomly select a bit p and flip it:
[0047] b′ p =1-b p
[0048] Among them, p is a randomly selected position, b p is the original value of the pth bit, b′ p is the flipped value;
[0049] Steps 1-3, construct a new binary representation and convert back to a floating point number w′:
[0050] w′=binary-to_float(b0b1...b p-1 b′ p b p+1 ...b m )
[0051] Among them, binary_to_float indicates the conversion of binary representation back to floating point number, and m+1 indicates the number of bits of binary representation binary_representation.
[0052] Further, in one embodiment, the standard Markov decision process of the agent interacting with the neural network model 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 is the state transition probability matrix, describing the probability of transitioning from one state to another; R a is the reward function, which defines the learning objective of the agent; γ∈[0,1] is the reward discount factor, which is 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 in step 3 specifically includes:
[0054] Step 3-1, define the state space, in each convolution 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] Among them, i represents the index of the network layer currently being processed; N represents the batch size, that is, the number of samples processed in one forward propagation; C represents the number of channels of 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 Indicates the computational effort of the i-th layer, in FLOPs; F used Indicates the total amount of computation of the convolution kernel selected in the previous layer; F rest represents the FLOPs allowed by the remaining layers according to the total computational budget; a i-1 YesL i-1 The action taken by the layer, 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 convolution kernels in each layer to perform TMR (triple modular redundancy) backup in each layer;
[0058] Define a continuous action space a t ∈[0, 1] to achieve fine adjustment of the redundant convolution kernels; and further restrict at each step to ensure that the action sequence meets the constraint of the target redundancy ratio α, specifically: define a minimum redundancy ratio a for each layer min , when it is expected that even if the minimum redundancy ratio a is applied to all remaining layers min When the computational budget is exceeded, the action a of the current layer will be truncated. t ; At the same time, a dynamic minimum redundancy ratio function δ(t) is introduced, which is adjusted according to 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 is the total FLOPs of all layers, F allow is the total FLOPs of the current layer, F follw is the total FLOPs of the remaining layers, L t represents the τth layer, F i represents the amount of computation at the tth layer;
[0061] Step 3-3, define the following reward function R acc Used to comprehensively consider average performance and worst performance:
[0062] R err =μ·accuracy average +(1-μ)acccuracy min
[0063] Among them, accuracyaverage Represents the average accuracy, accuracy min represents the minimum accuracy, and μ represents the weight.
[0064] Further, in one embodiment, the training optimization reinforcement learning SAC algorithm in step 4 to explore and predict the redundancy ratio of convolution kernels in each layer of the neural network specifically includes:
[0065] Step 4-1, initialize the neural network;
[0066] Step 4-2, through multiple iterations of training reinforcement learning SAC algorithm to optimize the policy network Actor and the value network Critic;
[0067] Step 4-3, use the reinforcement learning SAC algorithm trained and optimized in step 4-2 to search the neural network architecture and dynamically adjust the redundancy ratio of each layer of convolution kernels.
[0068] In some embodiments, the initialization of the neural network in step 4-1 specifically includes:
[0069] Initialize two Critic networks Q 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, w′2←w2 and initialize two target Critic networks respectively and
[0071] Initialize the experience replay pool R.
[0072] In some embodiments, the entire process of step 4-2 is implemented through three layers of loop nesting: 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 processes the decision and environmental response of each time step; the innermost layer is the training sample update loop of step 4-2-1-1-1, which improves the performance of the strategy by optimizing the network parameters; specifically including:
[0073] Set the number of sequence loops E, the number of time step loops T, and the number of training rounds K;
[0074] Step 4-2-1, the sequence loops from 1 to E, and the outermost loop runs E times. Each sequence loop represents a complete interaction cycle, starting a new sequence from the initial state s1 of the environment 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 cycle is from 1 to T, and at each time step in each sequence, execute:
[0076] (1) Randomly select action a according to the current strategy t =π θ (s t ), where s t Represents the environmental state corresponding to the current time step t;
[0077] (2) Execute action a t , get reward r t , the environment state becomes s t+1 .
[0078] (3) t , a t , r t ,s t+1 ) is deposited into the replay pool R;
[0079] Step 4-2-1-1-1, the number of training rounds is cycled from 1 to K, and execute:
[0080] (1) Sample N tuples {(s i , a i , r i ,s i+1 )} i=1,...,N ;
[0081] (2) For each tuple, use the target network to calculate where r i Indicates that the environment executes action a at the current time step i i Immediate reward, γ is the discount factor, between 0 and 1; Indicates that in the next state s i+1 and a i+1 The minimum of two different value networks under θ (a i+1 |s i+1 ) means that in a given state s i+1 Under the condition that θ The generated action probability distribution, θ is the parameter of the policy network; alogπ θ (a i+1 |s i+1 ) represents the entropy term of the strategy, α is the entropy coefficient, which is used to balance the exploration and utilization of the strategy, logπ θ (a i+1 |s i+1 ) represents the policy network π θ In status i+1 Next select action ai+1 The logarithm of the probability of .
[0082] (3) Perform the following updates on the two critic networks: for j = 1, 2, minimize the loss function
[0083] (4) Sampling a using the re-parameterization technique θ (s i ), and then updates 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, where τ is the soft update coefficient, which is used to control the influence of the main network parameters on the target network update.
[0086]
[0087]
[0088] Further, in one embodiment, in step 5, the importance score of the convolution kernel is calculated based on the neural network interpretability and the neuron integral gradient method, specifically including:
[0089] Step 5-1, calculate the importance score of each neuron in the convolutional layer by the neuron integral gradient method, the calculation formula is:
[0090]
[0091] In the formula, Cond y (x) represents the importance score of a neuron y under a 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 an integral variable with a value range of [0, 1], used to perform linear interpolation between the input x′ and the actual input x; y(ρ) represents the value of the neuron y under the interpolation parameter ρ, when ρ 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′), and x′+ρ(xx′) represents an interpolation that gradually transitions from x′ to the actual input x; Indicates that the output function F is equivalent to the partial derivative of the neuron y(ρ), indicating the rate of change of F when the neuron y(ρ) changes; is the rate of change of neuron y relative to the interpolation parameter ρ, indicating how neuron ρ changes when ρ changes; dρ is the differential element, indicating the increment when ρ is integrated;
[0092] Specifically, it accumulates the impact of neuron y(ρ) on the output F throughout the entire transition, thereby 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] Suppose the output of the convolutional layer is A, whose dimensions are (N, C, H, W), where N is the batch size, C is the number of channels (i.e., the number of convolution kernels), H is the feature map height, and W is the feature map width; for each neuron in the convolutional layer, use step 5-1 to calculate the importance of each output neuron 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 Indicates the importance of the neuron at the position of height H and width W under channel C in the Nth sample, Cond N,C,H,W (x) represents the importance of the neuron at position (H, W) under 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 works on all positions of the entire feature map, in order to quantify the global contribution of the convolution kernel, the importance scores of all neurons in the channel are summarized. Specifically, by averaging the importance scores of neurons in the height and width of the feature map, 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] It means that the importance scores of all H×W neurons in each channel C are averaged.
[0100] Further, in one embodiment, step 6 combines the SAC algorithm and the neural network interpretability to design an automatic model reinforcement framework such as Figure 2 As shown in the figure, important convolution kernels are reinforced with redundancy, including:
[0101] Step 6-1, designing the process of interaction between the SAC agent and the neural network model as a standard Markov decision process based on the method in step 3;
[0102] Step 6-2: For each layer, use the reinforcement learning SAC algorithm in step 4 to search layer by layer and predict the proportion of the key convolution kernel of the current layer;
[0103] Step 6-3, using the method in step 5, calculate the importance of the convolution kernels of the current layer and sort them, and locate the positions of the key convolution kernels;
[0104] Step 6-4: Use the convolution kernel redundancy reinforcement tool in step 2 to perform redundancy reinforcement on the key convolution kernels of the current layer, and then send the model to the fault test environment established in step 1. Use the fault tolerance test results as rewards to motivate the agent to update the strategy and immediately search and optimize the next layer;
[0105] Step 6-5: After all layers are traversed, the convolution kernel redundancy reinforcement tool in step 2 is used again to perform TMR backup on the key convolution kernels updated during the traversal process.
[0106] In one embodiment, an automatic model enhancement 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 test environment;
[0108] The second module is used to develop a batch fault injection tool for model weights to inject faults into multiple weights in the model at the same time, which is used to test the model's fault tolerance and establish a fault-tolerant test environment. At the same time, a convolution kernel redundancy reinforcement tool is developed to enhance the model's fault tolerance through redundant reinforcement and realize the automation of the model's fault-tolerant mechanism.
[0109] The third module is used to build 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;
[0110] The fourth module is used to train and optimize the reinforcement learning SAC algorithm to explore and predict the redundancy ratio of convolution kernels in each layer of the neural network and determine the optimal redundancy ratio of convolution kernels;
[0111] The fifth module is used to calculate the importance score of each convolution kernel based on the neuron integral gradient method, and sort the convolution kernels in descending order according to the score, and identify the convolution kernel with the greatest impact on the model performance as the key convolution kernel;
[0112] The sixth module is used to combine the reinforcement learning SAC algorithm and the principle of neural network interpretability to design an automatic model reinforcement framework and perform redundant reinforcement on the convolution kernel.
[0113] For the specific definition of the automatic model enhancement system based on neural network interpretability, please refer to the definition of the automatic model enhancement method based on neural network interpretability above, which will not be repeated here. Each module in the above-mentioned automatic model enhancement system based on neural network interpretability can be implemented in whole or in part through software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[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 when the processor executes the computer program, the following is achieved:
[0115] Step 1: Perform secondary development on PytorchFI to simulate hardware failures and build a failure test environment;
[0116] Step 2: Develop a batch fault injection tool for model weights to inject faults into multiple weights in the model at the same time, which is used to test the model's fault tolerance and establish a fault-tolerant test environment. At the same time, develop a convolution kernel redundancy reinforcement tool to enhance the model's fault tolerance through redundant reinforcement and realize the automation of the model's fault tolerance mechanism.
[0117] Step 3: Build 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 convolution kernels in each layer of the neural network and determine the optimal redundancy ratio of convolution kernels;
[0119] Step 5: Based on the neuron integral gradient method, calculate the importance score of each convolution kernel, sort the convolution kernels in descending order according to the score, and identify the convolution kernel with the greatest impact on the model performance as the key convolution kernel;
[0120] Step 6: Combining the reinforcement learning SAC algorithm and the principle of neural network interpretability, an automatic model reinforcement framework is designed to perform redundant reinforcement on the convolution kernel.
[0121] For the specific limitations of 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, on which a computer program is stored, and when the computer program is executed by a processor, the computer program implements:
[0123] Step 1: Perform secondary development on PytorchFI to simulate hardware failures and build a failure test environment;
[0124] Step 2: Develop a batch fault injection tool for model weights to inject faults into multiple weights in the model at the same time, which is used to test the model's fault tolerance and establish a fault-tolerant test environment. At the same time, develop a convolution kernel redundancy reinforcement tool to enhance the model's fault tolerance through redundant reinforcement and realize the automation of the model's fault tolerance mechanism.
[0125] Step 3: Build 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 convolution kernels in each layer of the neural network and determine the optimal redundancy ratio of convolution kernels;
[0127] Step 5: Based on the neuron integral gradient method, calculate the importance score of each convolution kernel, sort the convolution kernels in descending order according to the score, and identify the convolution kernel with the greatest impact on the model performance as the key convolution kernel;
[0128] Step 6: Combining the reinforcement learning SAC algorithm and the principle of neural network interpretability, an automatic model reinforcement framework is designed to perform redundant reinforcement on the convolution kernel.
[0129] For the specific limitations of 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, in one of the embodiments, the present invention is further verified and explained.
[0131] Figure 3 The performance loss comparison under different model redundancy reinforcement methods is shown, including the protection effect of the initial model, uniform redundancy reinforcement of each layer, manually setting the redundancy ratio reinforcement based on experience, and the convolutional neural network redundancy reinforcement framework (AMHR) based on neural network interpretability of the present invention. The horizontal axis represents the number of fault injections, and the vertical axis represents the accuracy rate (%).
[0132] In the experiment, the SAC algorithm was selected for model reinforcement training. VGG16 was used as the basic network, and the target redundancy rate α was set to 0.3 and the minimum redundancy rate a min The environment construction includes loading the correct model weights and the parameters of the wrong model. Then PytorchFI is used for fault injection to simulate the bit flip errors in real applications.
[0133] The original model, without redundancy protection, saw a rapid drop in accuracy as the number of fault injections increased. After 600 fault injections, the accuracy dropped to nearly 20%. This is because without any redundancy protection, the model is very sensitive to faults. Uniform redundancy ratio reinforcement for each layer (uniform), the method of uniform redundancy ratio reinforcement has a certain degree of improvement over the original model. After 600 fault injections, the accuracy is about 40%. This method improves the fault tolerance of the model by uniformly increasing redundancy in all layers, but the effect is limited because it fails to distinguish the importance of different layers. Manually set the redundancy ratio reinforcement based on experience (handcraft), the method of manually setting the redundancy ratio performs better than the uniform ratio redundancy reinforcement, and the accuracy is about 50% after 600 fault injections. This method relies on experience and sets different redundancy ratios for the importance of different layers, so it improves the fault tolerance of the model to a certain extent, but it is still not ideal. The convolutional neural network redundancy reinforcement framework (AMHR) based on neural network interpretability, the AMHR method performs best, and the accuracy remains close to 60% after 600 fault injections. This method calculates the importance of convolution kernels in the neural network and performs targeted redundant reinforcement, which significantly improves the fault tolerance and robustness of the model. This shows that the redundant reinforcement strategy based on the interpretability of the neural network can protect the model more effectively.
[0134] As can be seen from the above, the redundancy reinforcement method based on neural network interpretability (AMHR) shows the highest fault tolerance and the lowest performance loss when facing fault injection, which has significant advantages over other methods. By specifically reinforcing important convolution kernels, the AMHR method can more effectively improve the robustness of the model, thereby maintaining a high accuracy rate in a high-fault environment. This further verifies the potential application value of neural network interpretability in model optimization.
[0135] In summary, the model optimization method based on neural network interpretability and reinforcement learning proposed in the present invention selects important convolution kernels in a targeted manner through the neural network interpretability algorithm, providing explainable options for redundant reinforcement of the model. The SAC algorithm is combined with the model optimization to explore the redundant ratio of the convolution kernel, improve the fault detection rate and reduce the time and space overhead. At the same time, the flexible redundant reinforcement mechanism allows granular configurable redundancy for important convolution kernels, achieving a balance between efficient fault tolerance and economic benefits. By comparing with other related algorithms, it is further verified that the present invention can more efficiently perform fault detection and reinforcement in a variety of neural network architectures and application scenarios, thereby effectively realizing high-precision SDC error detection and redundant reinforcement at the model level.
[0136] The above shows and describes 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, and the above embodiments and descriptions are only for explaining the principles of the present invention. Without departing from the spirit and scope of the present invention, the present invention may have various changes and improvements, and these changes and improvements all fall within the scope of the present invention to be protected.
Claims
1. An automatic model enhancement method based on neural network interpretability, characterized in that: The method comprises the following steps: Step 1: Perform secondary development on PytorchFI to simulate hardware failures and build a failure test environment; Step 2: Develop a batch fault injection tool for model weights to inject faults into multiple weights in the model at the same time, which is used to test the model's fault tolerance and establish a fault-tolerant test environment. At the same time, develop a convolution kernel redundancy reinforcement tool to enhance the model's fault tolerance through redundant reinforcement and realize the automation of the model's fault tolerance mechanism. Step 3: Build 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 convolution kernels in each layer of the neural network and determine the optimal redundancy ratio of convolution kernels; Step 5: Based on the neuron integral gradient method, calculate the importance score of each convolution kernel, sort the convolution kernels in descending order according to the score, and identify the convolution kernel with the greatest impact on the model performance as the key convolution kernel; Step 6: Combining the reinforcement learning SAC algorithm and the principle of neural network interpretability, an automatic model reinforcement framework is designed to perform redundant reinforcement on the convolution kernel.
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 value into the binary representation of the IEEE 754 standard: binary_representation=S w E w M w Among them, S w is the sign bit, E w is the exponent bit, M w is the last digit; Step 1-2, randomly select a bit p and flip it: b′ p =1-b p Among them, p is a randomly selected position, b p is the original value of the pth bit, b' p is the flipped value; Steps 1-3, construct a new binary representation and convert back to a floating point number w': w′=binary_to_float(b0b1…b p-1 b′ p b p+1 …b m ) Among them, binary_to_float indicates the conversion of binary representation back to floating point number, and m+1 indicates the number of bits of 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 of the agent interacting with the neural network model in step 3 is represented by the five-tuple: (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 is the state transition probability matrix, describing the probability of transitioning from one state to another; R a is the reward function, which defines the learning objective of the agent; γ∈[0,1] is the reward discount factor, which is 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: The standard Markov decision process for designing the interaction between the agent and the neural network model described in step 3 specifically includes: Step 3-1, define the state space, in each convolution 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) Among them, i represents the index of the network layer currently being processed; N represents the batch size, that is, the number of samples processed in one forward propagation; C represents the number of channels of 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 Indicates the computational effort of the i-th layer, in FLOPs; F used Indicates the total amount of computation of the convolution kernel selected in the previous layer; F rest represents the FLOPs allowed by the remaining layers according to the total computational budget; a i-1 YesL i-1 The action taken by the layer, 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 convolution kernels in each layer to perform TMR backup in each layer; Define a continuous action space a t ∈[0,1] to achieve fine adjustment of the redundant convolution kernel; and further restrict at each step to ensure that the action sequence meets the constraint of the target redundancy ratio α, specifically: define a minimum redundancy ratio a for each layer min , when it is expected that even if the minimum redundancy ratio a is applied to all remaining layers min When the computational budget is exceeded, the action a of the current layer will be truncated. t ; At the same time, a dynamic minimum redundancy ratio function δ(t) is introduced, which is adjusted according to the characteristics of the current layer or other factors and is not a fixed value; the above strategy is described by the following formula: In the formula, F all is the total FLOPs of all layers, F allow is the total FLOPs of the current layer, F follw is the total FLOPs of the remaining layers, L t represents the tth layer, F i represents the amount of computation at the tth layer; Step 3-3, define the following reward function R acc Used to comprehensively consider average performance and worst performance: R err =μ·acccuiacy average +(1-μ)acccuiacy min Among them, accuracy average Indicates the average accuracy, accuracy min 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: The training optimization reinforcement learning SAC algorithm described in step 4 is used to explore and predict the redundancy ratio of convolution kernels in each layer of the neural network, including: Step 4-1, initialize the neural network; Step 4-2, through multiple iterations of training reinforcement learning SAC algorithm to optimize the policy network Actor and the value network Critic; Step 4-3, use the reinforcement learning SAC algorithm trained and optimized in step 4-2 to search the neural network architecture and dynamically adjust the redundancy ratio of each layer of convolution kernels.
7. The automatic model enhancement method based on neural network interpretability according to claim 6, characterized in that: Initializing the neural network in step 4-1 specifically includes: Initialize two Critic networks Q 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, w'2←w2 and 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: The entire process of step 4-2 is implemented through three layers of nested loops: 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 processes the decision and environmental response of each time step; the innermost layer is the training sample update loop of step 4-2-1-1-1, which improves the performance of the strategy by optimizing network parameters; Specifically include: Set the number of sequence loops E, the number of time step loops T, and the number of training rounds K; Step 4-2-1, the sequence loops from 1 to E, and the outermost loop runs E times. Each sequence loop represents a complete interaction cycle, starting a new sequence from the initial state s1 of the environment 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 cycle is from 1 to T, and at each time step in each sequence, execute: (1) Randomly select action a according to the current strategy t =π θ (s t ), where s t Represents the environmental state corresponding to the current time step t; (2) Execute action a t , get reward r t , the environment state becomes s t+1 . (3) t ,a t ,r t ,s t+1 ) is deposited into the replay pool R; Step 4-2-1-1-1, the number of training rounds is cycled from 1 to K, and execute: (1) Sample N tuples {(s i ,a i ,r i ,s i+1 )} i=1,…,N ; (2) For each tuple, use the target network to calculate where r i Indicates that the environment executes action a at the current time step i i The immediate reward, γ is the discount factor, between 0 and 1; Indicates that in the next state s i+1 and a i+1 The minimum of two different value networks under θ (a i+1 |s i+1 ) means that in a given state s i+1 Under the condition that θ The generated action probability distribution, θ is the parameter of the policy network; αlogπ θ (a i+1 |s i+1 ) represents the entropy term of the strategy, α is the entropy coefficient, which is used to balance the exploration and utilization of the strategy, logπ θ (a i+1 |s i+1 ) represents the policy network π θ In status i+1 Next select action a i+1 The logarithm of the probability of . (3) Perform the following updates on the two critic networks: for j = 1, 2, minimize the loss function (4) Sampling a using the re-parameterization technique θ (s i ), and then updates 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, τ 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, the importance score of the convolution kernel is calculated based on the neural network interpretability and the neuron integral gradient method, including: Step 5-1, calculate the importance score of each neuron in the convolutional layer by the neuron integral gradient method, the calculation formula is: In the formula, Cond y (x) represents the importance score of a neuron y under a given input x; x' is the baseline input, which represents a neutral or reference input; x is the actual input, which is used to calculate the importance of the corresponding neuron y under this input; ρ is an integral variable with a value range of [0,1], which is used to perform linear interpolation between the input x' and the actual input x; y(ρ) represents the value of the 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; Suppose the output of the convolutional layer is A, whose dimensions are (N, C, H, W), where N is the batch size, C is the number of channels (i.e., the number of convolution kernels), H is the feature map height, and W is the feature map width; for each neuron in the convolutional layer, use step 5-1 to calculate the importance of each output neuron 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 Indicates the importance of the neuron at the position of height H and width W under channel C in the Nth sample, Cond N,C,H,W (x) represents the importance of the neuron at position (H, W) under channel C for the Nth sample corresponding to input x; Step 5-3, calculate the importance of the convolution kernel, the calculation formula is: It means that the importance scores of all H×W neurons in each channel C are averaged.
10. The automatic model enhancement method based on neural network interpretability according to claim 6, characterized in that: Step 6 combines the SAC algorithm and neural network interpretability to design an automatic model reinforcement framework and perform redundant reinforcement on important convolution kernels, including: Step 6-1, designing the process of interaction between the SAC agent and the neural network model as a standard Markov decision process based on the method in step 3; Step 6-2: For each layer, use the reinforcement learning SAC algorithm in step 4 to search layer by layer and predict the proportion of the key convolution kernel of the current layer; Step 6-3, using the method in step 5, calculate the importance of the convolution kernels of the current layer and sort them, and locate the positions of the key convolution kernels; Step 6-4: Use the convolution kernel redundancy reinforcement tool in step 2 to perform redundancy reinforcement on the key convolution kernels of the current layer, and then send the model to the fault test environment established in step 1. Use the fault tolerance test results as rewards to motivate the agent to update the strategy and immediately search and optimize the next layer; Step 6-5: After all layers are traversed, the convolution kernel redundancy reinforcement tool in step 2 is used again to perform TMR backup on the key convolution kernels updated during the traversal process.
Citation Information
Patent Citations
Convolutional neural network fault injection system based on TensorFlow
CN111563578A
Winograd convolutional neural network vulnerability assessment method and device
CN114821082A
Small sample military vehicle lightweight detection method based on transfer learning
CN115439801A
Deep neural network generation method for reinforcement learning
CN115511077A
Near-end strategy optimization method based on graph convolutional neural network
CN115983373A
Cited By
Target detection network radiation hardening method facing AI chip of space spacecraft
CN121480587A
Radiation hardening method for target detection network of space spacecraft ai chip
CN121480587B