Software defect detection model interpretation method, device, equipment and storage medium
By converting deep convolutional neural networks into soft decision trees and using metric element sensitivity functions, a stable and transparent local interpretation of the software defect detection model is achieved, solving the problems of instable and unreliable results in the prior art.
Patent Information
- Application Number
- CN202310217413.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-08
- Publication Date
- 2025-09-02
- Estimated Expiration
- 2043-03-08
AI Technical Summary
The results of the existing software defect detection model interpretation method are unstable and unreliable, and cannot effectively explain the decision-making process of deep learning models.
By establishing a deep convolutional neural network, using knowledge distillation technology to convert the defect detection model into a soft decision tree, combining the metric element sensitivity function, quantifying the causal relationship between the prediction results and the input indicators, providing a stable local explanation.
It improves the transparency and stability of the software defect detection model, provides local interpretability, and solves the problems of instability and unreliability of results.
Smart Images

Figure CN116187452B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a software defect detection model interpretation method, device, equipment and storage medium. Background Art
[0002] Deep learning (DL), thanks to its remarkable feature engineering and function fitting capabilities, has significantly improved defect prediction performance and is gradually becoming a new paradigm in this research field. However, these incredible advances have been achieved through increased model complexity, turning predictive models into "black box" systems, rendering the generation of predictions impossible to explain. This lack of explainability makes deep learning-based predictions difficult to adopt in real-world applications.
[0003] The application of existing local interpretation methods in defect prediction has the following main shortcomings:
[0004] (1) Instability of interpretation results. Instability includes two aspects: using the same method to interpret the same prediction result multiple times will produce inconsistent results. Using different interpretation methods on the same prediction result will also produce inconsistent results.
[0005] (2) The interpretation results are unreliable. Local interpretation techniques are usually model-independent and use simple models (such as linear regression) to approximate deep neural networks. This strategy cannot simulate the complex feature engineering operations on the input data, so local interpretation methods cannot truly simulate the decision-making process of deep model-based predictors.
[0006] Therefore, how to provide a translucent and highly stable local interpretation method for defect detection is a technical problem that needs to be solved urgently. Summary of the Invention
[0007] The main purpose of the present invention is to provide a software defect detection model interpretation method, device, equipment and storage medium, aiming to solve the technical problems that the current software defect detection model interpretation has unstable and unreliable results.
[0008] To achieve the above object, the present invention provides a software defect detection model interpretation method, which includes the following steps:
[0009] Establish a deep convolutional neural network and use the sample data set to train the defect detection model and the probability of each metric element having a defect;
[0010] Perform knowledge distillation on the defect detection model to obtain the soft decision tree corresponding to the defect detection model;
[0011] Obtain a target data set, perform a weighting operation on each metric instance in the target data set, input the weighted data into a soft decision tree, and obtain a training loss for the soft decision tree;
[0012] Compare the training loss of each metric after adding weight to the loss of the defect detection model and take the difference;
[0013] The sensitivity of each metric is determined based on the result of the loss contrast difference, and the metric with the greatest impact on defect detection is determined based on the sensitivity.
[0014] Optionally, the sample data set is defect detection data with defect annotations.
[0015] Optionally, knowledge distillation is performed on the defect detection model to obtain a soft decision tree corresponding to the defect detection model, specifically including:
[0016] Input the trained defect detection model, sample data set, and the probability of each metric element having a defect into the knowledge distillation algorithm model;
[0017] The defect detection model is used as a teacher model in a knowledge distillation algorithm model, and the soft decision tree is used as a student model in the knowledge distillation algorithm model, and the soft decision tree after decision knowledge transfer is obtained through training.
[0018] Optionally, in the step of training the soft decision tree after the decision knowledge transfer, the expression of the training loss function is specifically:
[0019]
[0020] in:
[0021]
[0022]
[0023]
[0024]
[0025]
[0026] in, is the soft decision tree model loss relative to the true value, is the loss of the soft decision tree model logit relative to the teacher model logit, λ is a hyperparameter, is the true value of category i, is the probability of the soft decision tree model predicting category i, N is the number of inputs, is the logit of the student model, is the logit of the teacher model and T is the temperature hyperparameter.
[0027] Optionally, the step of training a soft decision tree after the decision knowledge transfer is obtained further includes:
[0028] A penalty factor is introduced; wherein the expression of the penalty factor is specifically:
[0029]
[0030]
[0031] in, From the root node to the node The path probability, is a node The actual average distribution of is the set of soft decision tree leaf nodes, The probability of choosing the right subtree for a soft decision tree.
[0032] Optionally, the method further includes: determining the standard deviation of each column of metrics in the target data set according to a given set of metrics, wherein the expression of the standard deviation of each column of metrics is specifically:
[0033]
[0034]
[0035] in, Metric element set Any metric in , N is the number of training data sets, is a sample of the training dataset No. indicators.
[0036] Optional, the expression of the training loss of the soft decision tree, specifically: ;
[0037] The expression of the loss is the result of the difference between the two, specifically: ;in, It is a measure Onehot encoding;
[0038] The expression of the sensitivity of each metric is:
[0039] .
[0040] In addition, in order to achieve the above-mentioned purpose, the present invention further provides a software defect detection model interpretation device, the software defect detection model interpretation device comprising:
[0041] The training module is used to build a deep convolutional neural network and use the sample data set to train the defect detection model and the probability of each metric element having a defect;
[0042] An acquisition module is used to perform knowledge distillation on the defect detection model to obtain a soft decision tree corresponding to the defect detection model;
[0043] An input module is used to obtain a target data set, perform a weighting operation on each metric instance in the target data set, input the weighted data into a soft decision tree, and obtain a training loss for the soft decision tree;
[0044] The subtraction module is used to compare the training loss of each metric after adding the amount of training with the loss of the defect detection model;
[0045] The determination module is used to determine the sensitivity of each metric element according to the result of the loss comparison, and determine the metric element with the greatest impact on defect detection according to the sensitivity.
[0046] In addition, in order to achieve the above-mentioned purpose, the present invention also provides a software defect detection model interpretation device, which includes: a memory, a processor, and a software defect detection model interpretation program stored on the memory and capable of running on the processor. When the software defect detection model interpretation program is executed by the processor, the steps of the above-mentioned software defect detection model interpretation method are implemented.
[0047] In addition, in order to achieve the above-mentioned purpose, the present invention also provides a storage medium, on which a software defect detection model interpretation program is stored. When the software defect detection model interpretation program is executed by a processor, the steps of the above-mentioned software defect detection model interpretation method are implemented.
[0048] The embodiments of the present invention propose a method, apparatus, device and storage medium for interpreting a software defect detection model. The method includes: establishing a deep convolutional neural network, using a sample data set to train a defect detection model and the probability of each metric element having a defect; performing knowledge distillation on the defect detection model to obtain a soft decision tree corresponding to the defect detection model; obtaining a target data set, performing a scaling operation on each metric element instance in the target data set, inputting the scaled data into the soft decision tree to obtain the training loss of the soft decision tree; comparing and subtracting the training loss of each metric element after scaling with the loss of the defect detection model; determining the sensitivity of each metric element based on the result of the loss comparison and subtraction, and determining the metric element with the greatest impact on defect detection based on the sensitivity. The present invention improves the transparency of the decision-making process and the stability of the interpretation, provides local interpretability, and solves the technical problems of unstable and unreliable results in the current interpretation of software defect detection models. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1 A schematic diagram of the device structure of the hardware operating environment involved in the embodiment of the present invention;
[0050] Figure 2 A flowchart of an embodiment of a software defect detection model interpretation method according to the present invention;
[0051] Figure 3 Schematic diagram of a deep convolutional neural network;
[0052] Figure 4 Schematic diagram of soft decision tree training;
[0053] Figure 5 This is a structural block diagram of a software defect detection model interpretation device in an embodiment of the present invention.
[0054] The purpose, features and advantages of the present invention will be further described with reference to the accompanying drawings and in conjunction with the embodiments. DETAILED DESCRIPTION
[0055] It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0056] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0057] like Figure 1 As shown, Figure 1 It is a schematic diagram of the device structure of the hardware operating environment involved in the embodiment of the present invention.
[0058] like Figure 1 As shown, the device may include: a processor 1001, such as a CPU, a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory or a stable memory (non-volatile memory), such as a disk memory. The memory 1005 may optionally be a storage device independent of the aforementioned processor 1001.
[0059] Those skilled in the art will understand that Figure 1 The structure of the device shown in the figure does not constitute a limitation of the device, and the device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0060] like Figure 1 As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a software defect detection model interpretation program.
[0061] exist Figure 1 In the terminal shown, the network interface 1004 is mainly used to connect to the backend server and communicate data with the backend server; the user interface 1003 is mainly used to connect to the client (user end) and communicate data with the client; and the processor 1001 can be used to call the software defect detection model interpretation program stored in the memory 1005 and perform the following operations:
[0062] Establish a deep convolutional neural network and use the sample data set to train the defect detection model and the probability of each metric element having a defect;
[0063] Perform knowledge distillation on the defect detection model to obtain the soft decision tree corresponding to the defect detection model;
[0064] Obtain a target data set, perform a weighting operation on each metric instance in the target data set, input the weighted data into a soft decision tree, and obtain a training loss for the soft decision tree;
[0065] Compare the training loss of each metric after adding weight to the loss of the defect detection model and take the difference;
[0066] The sensitivity of each metric is determined based on the result of the loss contrast difference, and the metric with the greatest impact on defect detection is determined based on the sensitivity.
[0067] The specific embodiments of the present invention applied to the device are basically the same as the embodiments of the following application software defect detection model interpretation method, and will not be described in detail here.
[0068] The embodiment of the present invention provides a software defect detection model interpretation method, referring to Figure 2 , Figure 2 Schematic diagram of the flow of an embodiment of the software defect detection model interpretation method of the present invention.
[0069] In this embodiment, the software defect detection model interpretation method includes the following steps:
[0070] Step S100: Establish a deep convolutional neural network and use the sample data set to train to obtain a defect detection model and the probability of each metric element having a defect;
[0071] Step S200: performing knowledge distillation on the defect detection model to obtain a soft decision tree corresponding to the defect detection model;
[0072] Step S300: Obtain a target data set, perform a weighting operation on each metric instance in the target data set, input the weighted data into a soft decision tree, and obtain a training loss of the soft decision tree;
[0073] Step S400, comparing the training loss of each metric after adding the amount of training with the loss of the defect detection model and taking the difference;
[0074] Step S500 : determining the sensitivity of each metric element based on the result of the loss contrast difference, and determining the metric element with the greatest impact on defect detection based on the sensitivity.
[0075] This embodiment provides a method for interpreting software defect detection models. By transferring the decision-making knowledge of a deep learning-based predictor into a soft decision tree, the prediction process can be interpreted as a series of "if-then" rules. Based on this, a metric sensitivity function is used to quantify the causal relationship between the prediction results and input indicators. This solution improves the transparency of the decision-making process and the stability of the interpretation, providing local interpretability and resolving the technical issues of unstable and unreliable interpretation results in current software defect detection model interpretation.
[0076] In order to explain the present application more clearly, specific examples of the present application in practical applications are provided below.
[0077] (1) For software defect prediction, existing technologies include:
[0078] Software defect prediction involves two phases: feature engineering and predictive modeling. Software metrics are widely used in feature engineering, converting static properties of code, such as cohesion, coupling, complexity, encapsulation, inheritance, and size, into numerical representations. Defect prediction is performed using metrics such as CK and QMOOD. Predictive models aim to indicate whether source code is defective or free of defects and are typically treated as binary classifications. Machine learning algorithms are the primary pillar of predictive model construction, and most practitioners prefer to use supervised and unsupervised learning algorithms when developing predictive models.
[0079] Because data labeling is labor-intensive and time-consuming, many practitioners tend to use unsupervised algorithms to build predictive models. However, statistics show that the performance of unsupervised models is far inferior to that of supervised models. Therefore, many practitioners use supervised algorithms to build defect predictors, believing that data labeling can provide more insights into defect prediction. Support Vector Machines (SVMs), random forests, and logistic regression have been widely used in existing research. In recent years, the complexity and scale of software systems have increased dramatically. The performance of traditional supervised learning-based methods has fallen short of practical requirements. This has led to the need to improve the performance of predictive models. Deep learning algorithms, with their excellent feature engineering and function fitting capabilities, have been increasingly applied to defect prediction, demonstrating excellent performance across various criteria. Yang et al. proposed the first deep learning-based defect predictor, Deeper. Experimental results show that Deeper detects 32.22% more defects than many traditional supervised learning algorithms. Inspired by Yang et al.'s findings, many researchers have proposed deep learning-based solutions. Hoang et al. proposed an end-to-end defect prediction model. Experimental results show that it outperforms Deeper. Qiao et al. proposed another deep learning-based model, DPNN, for predicting the number of defects in software systems. Experimental results showed that this method reduced the mean squared error by 14% and improved the squared correlation coefficient by 8%. Li et al. proposed a defect predictor, DP-CNN, based on a convolutional neural network (CNN). Experimental results showed that DP-CNN achieved superior performance to other state-of-the-art methods.
[0080] (2) Regarding interpretability defect prediction, existing technologies include:
[0081] Scholars have made numerous contributions to improving the interpretability of defect prediction models. Existing techniques can be broadly categorized into two types: global interpretability and local interpretability. Global interpretability methods focus on explaining the entire decision-making process of a specific predictor through interpretable machine learning algorithms (such as decision trees, decision rules, or logistic regression) or statistical methods (such as analysis of variance and variable importance). While global interpretability methods provide a clear view of the predictor's global workings, practitioners still struggle to understand how a specific code is predicted to be defective or not. These explanations provide little guidance for programmers in designing maintenance strategies for specific defects. Compared to global interpretability techniques, local interpretability techniques focus on identifying the causes of code defects or non-defects, providing programmers with more actionable guidance. Local interpretability methods such as LIME, BreakDown, SHAP, and Anchor are increasingly being used for defect prediction.
[0082] (3) Regarding knowledge distillation, in the existing technology:
[0083] Knowledge distillation is a typical model compression method. A complete knowledge distillation system should include three key components: knowledge, distillation algorithms, and a teacher-student architecture. The principle of knowledge distillation is to train a smaller student network to mimic the output of the teacher network, thereby compressing the model size.
[0084] A key reason deep networks lack interpretability is the sheer number of network parameters and the reliance on human-defined architectures. Knowledge distillation can effectively address this issue. Distillation compresses defect prediction networks, simplifying the model structure based on data distribution characteristics while maintaining predictive performance. This lays the foundation for further interpretation. Therefore, how to compress the model while preserving its good predictive performance becomes a crucial issue. Knowledge distillation provides the theoretical foundation for this concept.
[0085] Traditional knowledge distillation methods seek to create a student network with fewer parameters. However, compared to the teacher network, this lightweight network cannot effectively learn the underlying relationships previously hidden in the dataset. Therefore, the goal of distillation is to enable the student network to generalize to the teacher network. However, while the resulting student network is structurally simplified, it is still a neural network and therefore uninterpretable. The soft decision tree model used in this paper explicitly characterizes the teacher network's decision-making process as an if-then decision path while maintaining predictive performance. This ensures interpretability while maintaining predictive performance. Therefore, knowledge distillation lays the theoretical foundation for interpretable methods.
[0086] (4) In the existing technical solutions:
[0087] LIME: The general idea is to generate candidate instances by randomly perturbing the instances to be explained. The generated candidate instances and the output of the original instance to be explained on the model to be explained are used as training data. A linear model is fitted to the training data to obtain an explanation model. The features of this simple model are human-interpretable, and the trained weights can also represent feature importance. A surrogate model is trained to locally approximate the defect predictor and capture the corresponding explanation for a single prediction. The mechanism can be formalized as follows:
[0088]
[0089] where g is the explanatory model for a particular prediction x, and g is the set of all possible explanations, is the complexity of g. defines the range of instances x that are considered for interpretation. Practitioners must determine for themselves and the hyperparameters of G. Improper hyperparameter settings can lead to different interpretations of the same input. The core idea of LIME is to find a more easily interpretable proxy model for each sample to explain the original model.
[0090] However, existing local interpretation methods in defect detection have the following main problems: unstable interpretation results and unreliable interpretation results. Based on this, this specific example proposes a software defect detection model interpretation method, which mainly includes the following steps:
[0091] S1: Build a deep convolutional neural network and input the defect prediction dataset that has been defect-labeled into the deep convolutional neural network for training. Then, the trained deep convolutional neural network DP-CNN (i.e., the original defect prediction target model) and the probability of each metric element having a defect are obtained.
[0092] CNN is a special case of deep neural network. Compared with other deep learning-based models, the CNN-based defect predictor has achieved better performance. Therefore, the CNN-based defect predictor DP-CNN is selected as the target model. Figure 3 As shown in Figure 3, the deep convolutional neural network DP-CNN consists of three main modules: convolutional layer, maximum pooling layer and fully connected layer.
[0093] The convolutional layer extracts features from the input through different learnable kernels. The following two characteristics make it suitable for defect prediction: sparse connectivity and shared weights. The functionality of software can be abstracted as the interaction process between classes / methods. How to capture this correlation is of great significance to software function modeling. Existing predictors treat each class / method as an independent data and ignore the correlation between them. Sparse connectivity gives CNN a wider receptive field to capture local correlations between classes / methods. Shared weights mean that each CNN kernel has the same parameters, and the predictor is able to capture this correlation regardless of its position in the input.
[0094] Given an input matrix , the output of the convolutional layer It can be formally expressed as:
[0095]
[0096] in and are the learnable weights and biases of the kernel, is the convolution operator, is the activation function.
[0097] A limitation of convolution is that it is overly sensitive to changes in the position of the indicators in the input vector. Max pooling is a downsampling operation that selects the largest element from the convolution output. The output of max-pooling will contain the most prominent features from the previous operation, making the model more robust to changes in the position of the features in the input.
[0098] The fully connected layer is located at the end of the entire neural network layer and is responsible for converting the two-dimensional features of the convolution output into a one-dimensional vector to reduce the impact of feature position on classification.
[0099] S2: Input the previously trained DP-CNN, the defect prediction dataset, and the probability of a defect for each metric into the knowledge distillation algorithm model to transfer decision knowledge. Based on the trained target model, a knowledge distillation architecture is constructed. Training begins with the DP-CNN as the teacher model and the soft decision tree as the student model, obtaining a soft decision tree that transfers the decision knowledge from the DP-CNN.
[0100] The first step is to construct a soft decision tree. The soft decision tree is a variant of the fuzzy decision tree. It has a similar structure to the ordinary decision tree, but the definition of each node is different. The weight is defined as , bias is The neurons. The probability of a node choosing the rightmost branch is defined as
[0101]
[0102] in (·) is the activation function, It is The input features of the nodes.
[0103] In the second step, the decision-making knowledge of the target model is transferred to a soft decision tree using a knowledge distillation algorithm. The input is the probability of a defect in the DP-CNN metric from the previous step, denoted as soft, and the defect information annotated in the dataset, denoted as hard.
[0104] The generation process of soft decision tree is as follows Figure 4 As shown, the loss function of its training is defined as follows:
[0105]
[0106] is the soft decision tree model loss relative to the true value. is the loss of the soft decision tree model logit relative to the teacher model logit. The hyperparameter λ quantifies The importance of the loss.
[0107]
[0108] in is the true value of category i. is the probability of class i predicted by the soft decision tree model. N is the number of inputs. is the logit of the student model.
[0109]
[0110] in , is the teacher's logit model. , T is the temperature hyperparameter.
[0111] In the third step, a penalty term C is added. In order to encourage the model to fairly select the left and right subtrees, the penalty term C is introduced. Conventional loss can minimize the cross entropy between each leaf, while the penalty term can encourage the model to fairly select the left and right subtrees during distillation. The penalty term is the expected average distribution of the two subtrees 0.5, 0.5 and the actual average distribution The cross entropy between nodes of It is given by:
[0112]
[0113] in, From the root node to the node The path probability, The probability of choosing the right subtree for a soft decision tree.
[0114] The total penalty factor C is:
[0115]
[0116] in, is the set of soft decision tree leaf nodes.
[0117] Step 4: Observe the model's loss. When the loss is minimized, the student model approaches the teacher model's predictions, and decision-making knowledge is transferred from the teacher model to the student model. Record the model's loss at this point.
[0118] S3: Calculate the standard deviation of each column metric in the data set;
[0119] Given a set of metrics , first calculate the average value of each column metric, the calculation formula is:
[0120]
[0121] Where N is the number of training data sets, is a sample of the training dataset No. indicators.
[0122] Then calculate the standard deviation of each column metric using the following formula:
[0123]
[0124] S4: For a single metric instance in the dataset Perform the addition operation and send the added data into the soft decision tree model to obtain the training loss of the model, which is recorded as .in, yes The standard deviation of . It is a measure Onehot encoding.
[0125] S5: Compare the loss of the model trained after adding each metric element with the loss of the original model and make the difference;
[0126] Among them, the calculation formula for the change in the loss function of instance x is: .
[0127] S6: Calculate the sensitivity of the metric element. The metric element with the highest sensitivity is the metric element that has the greatest impact on the prediction results.
[0128] Given a training set , metric element set , instance x pairs The sensitivity of is defined as follows.
[0129]
[0130] The sensitivity function aims to quantify the correlation between the prediction result of instance x and the change of input indicators.
[0131] Therefore, this specific example leverages knowledge distillation technology to distill a difficult-to-interpret deep model into an easily interpretable soft decision tree. This achieves model interpretability while maintaining predictive accuracy, resolving the current problem of only deep models offering good predictive performance. To ensure local interpretability of the soft decision tree, a metric sensitivity function is creatively proposed. This quantifies the impact of the metric on predictive accuracy into specific numerical values, conveniently guiding developers in identifying defects. Unlike existing local interpretability methods, this method's decision path, once established, remains unchanged, addressing the issue of unstable interpretation results associated with existing interpretation methods.
[0132] Reference Figure 5 , Figure 5 This is a structural block diagram of an embodiment of the software defect detection model interpretation device of the present invention.
[0133] like Figure 5 As shown, the software defect detection model interpretation device proposed in the embodiment of the present invention includes:
[0134] The training module 2001 is used to establish a deep convolutional neural network and use the sample data set to train a defect detection model and the probability of each metric element having a defect;
[0135] An acquisition module 2002 is used to perform knowledge distillation on the defect detection model to obtain a soft decision tree corresponding to the defect detection model;
[0136] Input module 2003, used to obtain a target data set, perform a weighting operation on each metric instance in the target data set, input the weighted data into a soft decision tree, and obtain a training loss of the soft decision tree;
[0137] The subtraction module 2004 is used to compare the training loss of each metric after adding the amount of training with the loss of the defect detection model and perform the subtraction;
[0138] The determination module 2005 is configured to determine the sensitivity of each metric element according to the result of the loss comparison, and determine the metric element having the greatest impact on defect detection according to the sensitivity.
[0139] Other embodiments or specific implementations of the software defect detection model interpretation device of the present invention can refer to the above-mentioned method embodiments and will not be repeated here.
[0140] In addition, the present invention also proposes a software defect detection model interpretation device, characterized in that the software defect detection model interpretation device includes a memory, a processor, and a software defect detection model interpretation program stored on the memory and runnable on the processor, wherein: when the software defect detection model interpretation program is executed by the processor, the software defect detection model interpretation method described in each embodiment of the present invention is implemented.
[0141] The specific implementation of the software defect detection model interpretation device of the present application is basically the same as the various embodiments of the above-mentioned software defect detection model interpretation method, and will not be repeated here.
[0142] In addition, the present invention also proposes a readable storage medium, which includes a computer-readable storage medium on which a software defect detection model interpretation program is stored. The readable storage medium may be Figure 1The memory 1005 in the terminal may also be at least one of a ROM (Read-Only Memory) / RAM (Random Access Memory), a magnetic disk, and an optical disk. The readable storage medium includes a number of instructions for enabling a software defect detection model interpretation device having a processor to execute the software defect detection model interpretation method described in each embodiment of the present invention.
[0143] The specific implementation of the software defect detection model interpretation program in the readable storage medium of the present application is basically the same as the various embodiments of the above-mentioned software defect detection model interpretation method, and will not be repeated here.
[0144] It should be understood that, in the description of this specification, reference to terms such as "one embodiment," "another embodiment," "other embodiments," or "first to Nth embodiments" means that the specific features, structures, materials, or characteristics described in conjunction with that embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described may be combined in any appropriate manner in any one or more embodiments or examples.
[0145] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or system comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or system. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or system comprising the element.
[0146] The serial numbers of the above embodiments of the present invention are for description only and do not represent the advantages or disadvantages of the embodiments.
[0147] Through the description of the above embodiments, those skilled in the art can clearly understand that the above embodiment methods can be implemented by means of software plus the necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better embodiment. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present invention.
[0148] The above are only preferred embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention description and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A software defect detection model interpretation method, characterized in that: The method comprises the following steps: Establish a deep convolutional neural network and use the sample data set to train the defect detection model and the probability of each metric element having a defect; Perform knowledge distillation on the defect detection model to obtain the soft decision tree corresponding to the defect detection model; the loss function expression of the soft decision tree training is specifically: 、 in: 、 、 、 、 、 in, is the soft decision tree model loss relative to the true value, is the loss of the soft decision tree model logit relative to the teacher model logit, λ is a hyperparameter, is the true value of category i, is the probability of the soft decision tree model predicting category i, N is the number of inputs, is the logit of the student model, is the logit of the teacher model, and T is the temperature hyperparameter; Based on a given set of metrics, determine the standard deviation of each column of metrics in the target dataset. The expression for the standard deviation of each column of metrics is specifically: 、 、 in, Metric element set Any metric in , N is the number of training data sets, is a sample of the training dataset No. indicators; The expression of the training loss of the soft decision tree is: ; The expression of the loss is the result of the difference between the two, specifically: ;in, It is a measure Onehot encoding; The expression of the sensitivity of each metric is: 、 Obtain a target data set, perform a weighting operation on each metric instance in the target data set, input the weighted data into a soft decision tree, and obtain a training loss for the soft decision tree; Compare the training loss of each metric after adding weight to the loss of the defect detection model and take the difference; The sensitivity of each metric is determined based on the result of the loss contrast difference, and the metric with the greatest impact on defect detection is determined based on the sensitivity.
2. The software defect detection model interpretation method according to claim 1, wherein: The sample data set is defect detection data with defect annotations.
3. The software defect detection model interpretation method according to claim 1, wherein: Perform knowledge distillation on the defect detection model to obtain the soft decision tree steps corresponding to the defect detection model, including: Input the trained defect detection model, sample data set, and the probability of each metric element having a defect into the knowledge distillation algorithm model; The defect detection model is used as a teacher model in a knowledge distillation algorithm model, and the soft decision tree is used as a student model in the knowledge distillation algorithm model, and the soft decision tree after decision knowledge transfer is obtained through training.
4. The software defect detection model interpretation method according to claim 1, wherein: The training step of obtaining a soft decision tree after decision knowledge transfer also includes: A penalty factor is introduced; wherein the expression of the penalty factor is specifically: 、 、 in, From the root node to the node The path probability, is a node The actual average distribution of is the set of soft decision tree leaf nodes, The probability of choosing the right subtree for a soft decision tree.
5. A software defect detection model interpretation device, characterized in that: The software defect detection model interpretation device includes: The training module is used to build a deep convolutional neural network and use the sample data set to train the defect detection model and the probability of each metric element having a defect; The acquisition module is used to perform knowledge distillation on the defect detection model to obtain the soft decision tree corresponding to the defect detection model; the expression of the loss function of the soft decision tree training is specifically: 、 in: 、 、 、 、 、 in, is the soft decision tree model loss relative to the true value, is the loss of the soft decision tree model logit relative to the teacher model logit, λ is a hyperparameter, is the true value of category i, is the probability of the soft decision tree model predicting category i, N is the number of inputs, is the logit of the student model, is the logit of the teacher model, and T is the temperature hyperparameter; Based on a given set of metrics, determine the standard deviation of each column of metrics in the target dataset. The expression for the standard deviation of each column of metrics is specifically: 、 、 in, Metric element set Any metric in , N is the number of training data sets, is a sample of the training dataset No. indicators; The expression of the training loss of the soft decision tree is: ; The expression of the loss is the result of the difference between the two, specifically: ;in, It is a measure Onehot encoding; The expression of the sensitivity of each metric is: 、 An input module is used to obtain a target data set, perform a weighting operation on each metric instance in the target data set, input the weighted data into a soft decision tree, and obtain a training loss for the soft decision tree; The subtraction module is used to compare the training loss of each metric after adding the amount of training with the loss of the defect detection model; The determination module is used to determine the sensitivity of each metric element according to the result of the loss comparison, and determine the metric element with the greatest impact on defect detection according to the sensitivity.
6. A software defect detection model interpretation device, characterized in that: The software defect detection model interpretation device includes: a memory, a processor, and a software defect detection model interpretation program stored in the memory and executable on the processor. When the software defect detection model interpretation program is executed by the processor, the steps of the software defect detection model interpretation method according to any one of claims 1 to 4 are implemented.
7. A storage medium, characterized in that: The storage medium stores a software defect detection model interpretation program, which, when executed by a processor, implements the steps of the software defect detection model interpretation method according to any one of claims 1 to 4.