Deep neural network repairing method based on neural weight positioning and constraint solution

By calculating the classification contribution and gradient loss of neural weights, key weights in deep neural networks are located and repaired, symbolic network models are generated and constraints are set, and the problem of high cost and unguaranteed calculation of deep neural network repair in the existing technology is solved, achieving efficient and reliable repair results.

CN119647545AInactive Publication Date: 2025-03-18SICHUAN UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411859226.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-17
Publication Date
2025-03-18
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In the problem that existing deep neural network repair methods are expensive to calculate and do not guarantee the repair effect, how to effectively repair the misclassification behavior of deep neural networks, especially in security-related scenarios.

Method used

By calculating the classification contribution and gradient loss of neural weights to negative and positive samples, neural weights that have a large impact on negative samples but have a small impact on positive samples are located and used as a repair target. Then, a symbolic network model is generated, constraints are set to ensure that the output of the model meets the original activation situation, and the model weight is updated through the solver to achieve repair.

Benefits of technology

该方法通过精准定位和修复关键神经权重,有效修复深度神经网络的错误分类行为,降低了计算代价,并保证了修复效果的可靠性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119647545A_ABST
    Figure CN119647545A_ABST
Patent Text Reader

Abstract

The invention relates to a repair problem of a deep neural network, and the method comprises the steps: firstly, carrying out the weighted calculation of a comprehensive influence value of each neural weight based on the classification contribution degree and gradient loss of the neural weight to positive and negative samples, and selecting the first k% neural weight of a layer with the highest comprehensive influence value as a to-be-repaired weight; then setting a modification value of a weight to be repaired as a symbol variable, generating a symbol network model, calculating a symbol output value of a negative sample before each layer of activation function on the symbol network model, and generating a constraint condition for the symbol network model according to an activation condition of the sample on an original model; generating constraint conditions for repairing error behaviors in an output layer; and finally, solving the value of the symbol variable through a solver, and updating the weight of the model. According to the method, the neural weight which has relatively high influence on the negative sample but relatively small influence on the positive sample is selected as the repair target, and the modification on the model is as small as possible through the constraint condition and the target function in the repair process, so that the influence on the correct behavior of the model is avoided, and the repair of the wrong behavior is ensured through the constraint condition.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of software repair in software engineering, and in particular to a deep neural network repair method based on neural weight positioning and constraint solving. Background Art

[0002] With the rapid development of deep neural networks, software systems based on deep neural networks are becoming more and more common today. They are deployed in many application areas, but current DNN systems are still far from perfect, and their erroneous behaviors may lead to harmful or even fatal consequences, especially those deployed in safety-critical scenarios. When DNN exhibits serious erroneous behaviors, how to effectively repair them is an important issue.

[0003] Most existing deep neural network repair methods use the method of expanding the training set and retraining to repair the model, but the computational cost of retraining is expensive. Some other studies have made targeted and focused improvements. After locating the neural weights using gradient or causal analysis methods, two optimization goals are set: maintaining the original correct classification and repairing the wrong classification. The weight parameters are adjusted using heuristic search algorithms, but heuristic repair methods cannot guarantee the repair effect. Summary of the invention

[0004] In order to improve the repair effect of deep neural networks, the present invention proposes a deep neural network repair method based on neural weight positioning and constraint solving for the misclassification behavior of deep neural networks. The specific repair process includes the following three steps:

[0005] Step 1, locate the neural weights to be repaired;

[0006] Directly using all neural weights as repair targets will cause significant changes to the model, and even a relatively simple deep neural network has thousands of weight parameters. Modifying all weights is expensive, so it is necessary to select some neural weights as repair targets. The neural weights that have a large impact on negative samples but a small impact on positive samples can be located through the model's classification contribution to positive and negative samples and the gradient loss.

[0007] The step 1, locating the neural weights to be repaired, comprises the following steps:

[0008] Step 1-1, calculate the contribution of neural weights to the classification of negative samples and positive samples;

[0009] The classification contribution can measure the impact of neural weights on the final classification results of samples. It can locate neural weights that contribute greatly to the classification of negative samples but less to the classification of positive samples.

[0010] Step 1-2, calculate the gradient loss of neural weights on negative samples and positive samples;

[0011] Gradient loss can measure the responsibility of neural weights for misclassification. It can identify neural weights with large gradient loss on negative samples but small gradient loss on positive samples.

[0012] Step 1-3, calculate the comprehensive influence value of neural weights based on classification contribution and gradient loss;

[0013] The classification contribution and gradient loss measure the impact of neural weights on sample classification from two different aspects. These two parts are weighted to obtain the comprehensive impact value of the neural weights.

[0014] Step 1-4, select the first k% neural weights of the layer with the highest comprehensive influence value as the weights to be repaired;

[0015] In order to minimize the modification of the model and make the solution efficiency as high as possible, the target to be repaired is located in a layer that has a large impact on negative samples but a small impact on positive samples, and the neural weights with the top k% of the comprehensive impact value of this layer are selected.

[0016] Step 2, generating constraints for model repair;

[0017] The step 2, generating the constraint conditions for model repair, comprises the following steps:

[0018] Step 2-1, setting the modified value of the weight to be repaired as a symbolic variable to generate a symbolic network model;

[0019] Step 2-2, obtain the activation Φ of each layer of the negative sample in the original network model;

[0020] After setting the symbolic variables, when the sample input model is forward propagated, the activation of the neurons before the repair layer is determined, but the output values ​​before the activation function of each layer after the repair layer are all symbolic output values, that is, expressions containing multiple symbolic variables. There are two cases after the value passes through the Relu function, resulting in the output of each neuron being uncertain, and the symbolic output value of the output layer cannot be determined. To solve this problem, it is necessary to constrain the output of each neuron before the output layer. The present invention uses the activation status of each layer of the sample on the original model as a reference, and constrains the output of the sample in the middle layer of the symbolic network model, so that the symbolic output value of the output layer can be determined, and the modification of the model can be ensured to be as small as possible.

[0021] Step 2-3, negative samples are input into the signed network model, and the output value with a sign in the middle layer is set to satisfy the activation condition Φ;

[0022] The output values ​​of the intermediate layers with signs are set to meet the reference activation to determine the output of each layer of the model and finally determine the sign output value of the output layer.

[0023] Step 2-4, set the symbol output value corresponding to the original label in the output layer to be the maximum;

[0024] The correct way to fix the incorrect behavior of the model is to maximize the symbol output value corresponding to the original label in the output layer when the model predicts negative samples.

[0025] Step 3, use the solver to solve and update the model weights;

[0026] The step 3, solving with a solver and updating the model weights, comprises the following steps:

[0027] Step 3-1, add solver constraints;

[0028] Step 3-2, set the solver objective function to minimize the sum of the absolute values ​​of all symbolic variables;

[0029] The symbolic variable is the value to be added to each weight to be repaired. To achieve the minimum modification to the model, the value of the symbolic variable needs to be constrained. The solution of the symbolic variable may be negative, so the objective function of the solver is set to the minimum sum of the absolute values ​​of all symbolic variables.

[0030] Step 3-3, solve using solver;

[0031] Step 3-4, update the model weights.

[0032] The present invention relates to the repair problem of deep neural network. First, based on the classification contribution and gradient loss of neural weights to positive and negative samples, the comprehensive influence value of each neural weight is weighted and calculated, and the first k% neural weights of the layer with the highest comprehensive influence value are selected as the weights to be repaired; then the modification value of the weight to be repaired is set as a symbolic variable, a symbolic network model is generated, the symbolic output value of the negative sample before each layer activation function on the symbolic network model is calculated, and constraints are generated for the symbolic network model according to the activation of the sample on the original model, and constraints for repairing wrong behaviors are generated in the output layer; finally, the value of the symbolic variable is solved by a solver to update the model weight. The present invention selects the neural weights that have a higher influence on negative samples but a smaller influence on positive samples as the repair target, and in the repair process, the modification of the model is minimized as much as possible through constraints and objective functions to avoid affecting the correct behavior of the model, and the repair of wrong behaviors is guaranteed by constraints. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] Figure 1 It is a flow chart for implementing the method of the present invention. DETAILED DESCRIPTION

[0034] In order to more clearly demonstrate the purpose and technical solution of the present invention, the specific implementation methods and parameters of the present invention will be described in more detail below in combination with the specific implementation process and drawings.

[0035] A deep neural network inpainting method based on neural weight localization and constraint solving, such as Figure 1 As shown, the following steps are included:

[0036] Step 1, locate the neural weights to be repaired;

[0037] The step 1 is to locate the neural weights to be repaired, such as Figure 1 As shown in S1 in FIG. 1 , the following steps are included:

[0038] Step 1-1, calculate the contribution of neural weights to the classification of negative samples and positive samples;

[0039] The neural weight has a significant impact on the final classification result, which means that the weight has a great influence on the activation value of the output neuron connected to it, and the output neuron can affect the final classification result. and The neural weights By With neurons The average activation value on negative samples Multiply to estimate weights For output neurons The influence of activation value; then use DeepLift tool to calculate the neuron Average classification contribution to all negative samples The neural weight Contribution to the classification of negative samples The calculation method is as follows

[0040] As shown in formula 1:

[0041]

[0042] Similarly, we can find the contribution of neural weights to the classification of positive samples.

[0043] Step 1-2, calculate the gradient loss of neural weights on negative samples and positive samples;

[0044] Use back propagation of the network model to calculate the neural weights Gradient loss on negative samples and the gradient loss on the positive samples

[0045] Step 1-3, calculate the comprehensive influence value of neural weights based on classification contribution and gradient loss;

[0046] Assign weighted proportions α and β to classification contribution and gradient loss, neural weights The comprehensive impact value The calculation method is shown in Formula 2:

[0047]

[0048] Step 1-4, select the first k% neural weights of the layer with the highest comprehensive influence value as the weights to be repaired;

[0049] After calculating the comprehensive influence values ​​of all neural weights, calculate the sum of the comprehensive influence values ​​of each layer weight, select the layer with the largest sum of influence values, and select the first k% of neural weights of this layer as the weights to be repaired.

[0050] Step 2, generating constraints for model repair;

[0051] Step 2, generating constraints for model repair, such as Figure 1 As shown in S2 in FIG. 1 , the following steps are included:

[0052] Step 2-1, setting the modified value of the weight to be repaired as a symbolic variable to generate a symbolic network model;

[0053] For each repair weight W i Add symbolic variable δ i , weight W i becomes the symbol weight W i +δ i , generating a symbolic network model. When the sample is input into the network model for forward propagation, the symbolic weights are used for calculation before and after the repair layer.

[0054] Step 2-2, obtain the activation Φ of each layer of the negative sample in the original network model;

[0055] The negative sample X i Input the original network model and forward propagate to get neuron N j The activation status of the neuron is that if the output value of the neuron is equal to 0, it is not activated, and if the output value is greater than 0, it is activated.

[0056] Step 2-3, negative samples are input into the signed network model, and the output value with a sign in the middle layer is set to satisfy the activation condition Φ;

[0057] The negative sample X i Input the symbolic network model, calculate the output value of the previous layer of the repair layer, and use the symbolic neural weights for forward propagation in the repair layer to obtain the neuron N of the repair layer. j Symbolic output value output before the Relu activation function j The format of the symbol output value is shown in Formula 3, where output ori It is neuron N j The output value before the activation function on the original network model, ai is the symbolic variable δ i The coefficients of , which are calculated during the forward propagation of the model.

[0058] output j = output ori + Σa i ×δ i (Formula 3)

[0059] If the neuron N j In the original network model, it is activated, so neuron N is set j Symbolic output values ​​in symbolic network models j Greater than or equal to 0, output after Relu function j ; If neuron N j In the original network model, it is not activated, so neuron N is set j Symbolic output values ​​in symbolic network models j Less than or equal to 0, after passing through the Relu function, the output is 0. The output of each layer of neurons after the repair layer is calculated in the same way.

[0060] Step 2-4, set the symbol output value corresponding to the original label in the output layer to be the maximum;

[0061] After the forward propagation of steps 2-3, the symbol output values ​​corresponding to each label of the output layer can be obtained, and each symbol output value is set to be less than or equal to the symbol output value corresponding to the original label.

[0062] Step 3, use the solver to solve and update the model weights;

[0063] In step 3, the solver is used to solve and update the model weights, such as Figure 1 As shown in S3 in the figure, it includes the following steps:

[0064] Step 3-1, add solver constraints;

[0065] All negative samples generate repair constraints in the manner of steps 2-3 and 2-4, and add the constraints to the solver.

[0066] Step 3-2, set the solver objective function to minimize the sum of the absolute values ​​of all symbolic variables;

[0067] For each symbolic variable δ i Add a corresponding symbolic variable θ i , by adding the constraint θ i >=δ i and θ i >=-δ i So that θi >=|δ i |, set the objective function of the solver to ∑θ i The value of is the smallest.

[0068] Step 3-3, solve using solver;

[0069] Use the Gurobi solver to solve all symbolic variables δ i The solution.

[0070] Step 3-4, update model weights;

[0071] Traversing symbolic variables δ i , add its solution value to the neural weight of the corresponding position of the original model, save the modified weight file, and get the repaired model.

Claims

1. A deep neural network repair method based on neural weight positioning and constraint solving, characterized in that: The following steps are involved: Step 1, locate the neural weights to be repaired; Step 2, generating constraints for model repair; Step 3: Use the solver to solve and update the model weights.

2. The method according to claim 1, characterized in that The step 1, locating the neural weights to be repaired, comprises the following steps: Step 1-1, calculate the contribution of neural weights to the classification of negative samples and positive samples; Step 1-2, calculate the gradient loss of neural weights on negative samples and positive samples; Step 1-3, calculate the comprehensive influence value of neural weights based on classification contribution and gradient loss; Steps 1-4: Select the first k% neural weights of the layer with the highest comprehensive influence value as the weights to be repaired.

3. The method according to claim 1, characterized in that The step 2, generating constraint conditions for model repair, includes the following steps: Step 2-1, setting the modified value of the weight to be repaired as a symbolic variable to generate a symbolic network model; Step 2-2, obtain the activation Φ of each layer of the negative sample in the original network model; Step 2-3, negative samples are input into the signed network model, and the output value with a sign in the middle layer is set to satisfy the activation condition Φ; Step 2-4, set the symbol output value corresponding to the original label in the output layer to be the maximum.

4. The method according to claim 1, characterized in that The step 3, solving with a solver and updating the model weights, comprises the following steps: Step 3-1, add solver constraints; Step 3-2, set the solver objective function to minimize the sum of the absolute values ​​of all symbolic variables; Step 3-3, solve using solver; Step 3-4, update the model weights.