A software model mutation method for AI systems based on neuron characteristics
By using the AI system software model mutation method in the deep learning system to calculate the diversity degree and mutation score of the test set, the problem of test set quality assessment in the deep learning system is solved, and the testing efficiency and system quality assurance are improved.
Patent Information
- Application Number
- CN202110658162.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-11
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2041-06-11
AI Technical Summary
In deep learning systems, it is difficult to directly evaluate the quality of test sets with existing technologies, resulting in low testing efficiency and failure to fully discover potential defects.
The AI system software model mutation method oriented to neuron characteristics is used to automatically select the mutation level by calculating the distance entropy and diversity degree of the test set, generate a mutation model, and calculate the mutation score to evaluate the quality of the test set.
This method can quickly and accurately evaluate the quality of the test set, reduce invalid testing time, and improve the testing efficiency of deep learning models and system development efficiency.
Smart Images

Figure CN113342662B
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of deep learning testing, and is particularly suitable for the field of test adequacy measurement in deep learning testing. Its purpose is to solve the problem of deep learning system test set quality assessment. It is a method to help software testers improve test effectiveness and ensure the quality of deep learning systems. Background Art
[0002] Deep learning defines a new data-driven paradigm. Unlike traditional software, the internal logic of deep learning systems is driven by data sets. Today, deep learning technology has developed rapidly and has gradually become a key technology in the field of artificial intelligence, and has achieved remarkable success in many important applications. However, with its widespread application, the quality of deep neural network systems has also been focused on. Due to the complex structure of deep neural networks, even if small perturbations in the data cannot be detected by humans, they may cause deep neural networks to make wrong judgments and output wrong results. In particular, deep neural networks are increasingly deployed in safety-critical fields such as autonomous vehicle systems, malware detection systems, and aircraft collision avoidance systems. Therefore, it is crucial to fully test such deep learning systems and ensure their quality. Due to the characteristics of deep learning systems, test sets play an important role in the testing process. A good test set can fully test the general behavior of deep learning systems and their behavior under various boundary conditions, and find as many model defects as possible. This shows that finding a high-quality test set is a very important task.
[0003] How to evaluate the quality of the test set is an important research question. When the number of errors in the system is known, the more errors the test set can detect, the higher the quality of the test set. However, in actual scenarios, the total number of defects in deep learning systems is unknown. In this regard, R&D personnel can only rely on other means to evaluate the quality of the test set. Neuron coverage is an effective indicator for evaluating the quality of the test set and discovering model defects: first, the threshold of the neuron is calculated during the training process; second, the neuron coverage is calculated using the test set; finally, the adequacy of the test model and the quality of the test set are evaluated by the neuron coverage. The higher the neuron coverage, the higher the adequacy of the test, the greater the possibility of discovering potential defects, and the higher the quality of the test set. However, this test standard is model-dependent and can only reflect the quality of the test set through the neuron coverage of the model during the test process. At the same time, the quality of the test set is related to the possibility of discovering defects, not the number of defects. Therefore, we need a method to directly evaluate the quality of the test set before testing. Mutation testing is an effective method for evaluating the error detection capability of test cases. In traditional software, mutation testing has become one of the important technologies for systematically evaluating the quality of test data and locating test data defects. Among them, the most critical step is to design and select mutation operators to introduce potential errors into the software under test, thereby generating software variants. The quality of the test case set is evaluated by comparing the performance differences between the source program and the mutant program on the test case set. The greater the difference, the higher the quality of the test case set.
[0004] In this regard, the present invention proposes a method for AI system software model mutation based on neuron characteristics. The basic idea of the present invention is to migrate the idea of traditional software mutation testing to the testing of deep learning systems, use the mutation operator of deep learning to mutate the model, and observe how many defects of the mutation model can be exposed by the data of the test set, as the evaluation standard of the quality of the test set. First, calculate the distance entropy of the data subset of each category in the test set, that is, the degree of diversity of each class subset, quantify the overall diversity of the test set according to the average distance entropy of the entire test set, and automatically select the corresponding mutation level; on this basis, select the mutation operator of the corresponding level, and mutate to obtain multiple mutation models; finally, filter out the mutation models with low precision, calculate the mutation scores of the remaining mutation models, and effectively evaluate the quality of the test set.
[0005] This method can help testers quickly and accurately obtain the variation score of the test set, and then evaluate the quality of the test set, reducing invalid testing time due to low quality of the test set, thereby effectively improving the testing time of the deep learning model and the R&D efficiency of the system. Summary of the invention
[0006] The present invention provides an AI system software model mutation method for neuron characteristics to effectively solve the current deep learning system test set quality assessment problem. The use of mutation score indicators can help software developers accurately evaluate test sets and ensure the quality of deep learning systems.
[0007] To achieve the above objectives, the present invention proposes a method for AI system software model mutation based on neuron characteristics. First, the distance entropy distance_entropy of the data subset of each category in the test set is calculated, that is, the degree of diversity of each class subset, and the overall diversity degree div_value of the test set is quantified according to the average distance entropy of the entire test set, and the corresponding mutation level mutation_level is automatically selected; on this basis, the mutation operator source_operator or model_operator of the corresponding level is selected, and multiple mutation models mutation_model are obtained by mutation; finally, the mutation models with low precision are screened out, and the mutation scores mutation_score of the remaining mutation models are calculated to effectively evaluate the quality of the test set. Specifically, the method includes the following steps.
[0008] 1) Automatic selection of mutation level. Given a test set TS = {TS1, TS2, ..., TS n}. Among them, the subset TS of each class k ={t k,1 , t k,2 ,…,t k,m}. Using Euclidean distance(t k,i , t k,j ) calculate and save TS using the distance matrix matrix k The distance between two pairs of data in . The calculation formula of Euclidean distance is as follows:
[0009]
[0010] n represents the dimension of data x and y, calculate the minimum spanning tree tree of the distance matrix matrix, and add the weighted edges of tree to the set W, where W = {w1, w2, ..., W m-1}. Calculate TS based on W k The distance entropy dis_entropy is calculated as follows:
[0011]
[0012] in,
[0013] For n test subsets, calculate the average value of dis_entropy div_value and compare it with div_threshold to get the corresponding mutation level mutation_level. The calculation formula is as follows:
[0014]
[0015] The purpose of this step is to automatically select the mutation level suitable for the test set based on the diversity of the test set. Specifically, for a test set with a high degree of diversity, it is suitable to use model-level mutation testing; on the contrary, for a test set with a low degree of diversity, it is suitable to use source-level mutation testing.
[0016] 2) Mutation model generation. According to the mutation level mutation_level, select the corresponding process to generate multiple mutation models mutation_model. For the source mutation level source, use the source mutation operator source_operator to mutate the original training program OP, then train OP with the training set TT, and add the trained mutation model mutation_model to the mutation model set VM; for the model mutation level model, use OP and TT to train the original model origin_model, then use the model mutation operator model_operator to mutate origin_model, and add mutation_model to VM.
[0017] 3) Mutation score calculation. Given the precision threshold pre_threshold, the mutation model set VM and the test set TS = {TS1, TS2, ..., TS n First, if there is a mutation model mutation_model in VM and the precision pre_radio is lower than pre_threshold, mutation_model will be deleted from VM to eliminate the differences in the model caused by other reasons besides the introduction of mutation operators; then, if TS k There is data t k,i It is judged as TS on the original model origin_model k Class, but not judged as TS on mutation_model k class, then add 1 to the number of detection classes. Finally, calculate the ratio of the number of detection classes of mutation_model to the number of all classes, and add them up to get the total score total_score. Use the size() function to calculate the total number of mutation models in VM size(VM), and find the average value of total_score, which is the final mutation score mutation_score of TS.
[0018] Further, the specific steps of the above step 1) are as follows:
[0019] Step 1)-1: Starting state;
[0020] Step 1)-2: Input classification test set TS = {TS1, TS2, ..., TS n}, test set diversity threshold div_threshold;
[0021] Step 1)-3: Initialize the mutation level to the source level, denoted as mutation_level=source, test set diversity value div_value=0, k=1, and execute step 1)-5;
[0022] Step 1)-4: k++;
[0023] Step 1)-5: Take out the test set subset TS k ={t k,1 , t k,2 ,…,t k,m};
[0024] Step 1)-6: Create a new m*m distance matrix matrix, i=1, j=1;
[0025] Step 1)-7: Calculate the distance between the i-th and j-th data and save it in the distance matrix matrix. The calculation formula is as follows:
[0026] matrix i,j = distance(t k,i , t k,j )
[0027] matrix j,i = distance(t k,i , t k,j )
[0028] Step 1)-8: j++;
[0029] Step 1)-9: Determine whether j>m is established, if so, execute step 1)-10, otherwise execute step 1)-7;
[0030] Step 1)-10: i++, j=i+1;
[0031] Step 1)-11: Determine whether i>m-1 is established, if so, execute step 1)-12, otherwise execute step 1)-7;
[0032] Step 1)-12: Generate the minimum spanning tree tree of matrix;
[0033] Step 1)-13: Generate a tree weight set W = {w1, w2, ..., w m-1};
[0034] Step 1)-14: Calculate the weight sum w of set W sum , and its calculation formula is as follows:
[0035]
[0036] Step 1)-15: Initialize distance entropy dis_entropy=0;
[0037] Step 1)-16: Calculate the distance entropy dis_entropy of the weight set W, and the calculation formula is as follows:
[0038]
[0039] Step 1)-17: Add the average value of dis_entropy relative to all classes to div_value, which is calculated as follows:
[0040]
[0041] Step 1)-18: Determine whether k<n is established, if so, execute step 1)-19, otherwise execute step 1)-4;
[0042] Step 1)-19: Determine whether div_value<div_threshold is established, if so, execute step 1)-20, otherwise execute step 1)-21;
[0043] Step 1)-20: The mutation level is the model level, denoted as mutation_level=model;
[0044] Step 1)-21: Output mutation_level;
[0045] Step 1)-22: End state.
[0046] Further, the specific steps of the above step 2) are as follows:
[0047] Step 2)-1: Starting state;
[0048] Step 2)-2: Input training set TT, test set TS, original training program OP, mutation operator set MO, mutation level mutation_level;
[0049] Step 2)-3: Initialize the mutation model set
[0050] Step 2)-4: Determine whether mutation_level == source is true, if so, execute step 2)-5, otherwise execute step 2)-10;
[0051] Step 2)-5: Select the source mutation operator source_operator from MO;
[0052] Step 2)-6: Use source_operator to mutate OP to obtain the mutated training program VP;
[0053] Step 2)-7: Use VP and TT to train and obtain the mutation model mutation_model;
[0054] Step 2)-8: Add mutation_model to VM;
[0055] Step 2)-9: Determine whether the traversal of the source-level mutation operator is complete. If so, execute step 2)-10; otherwise, execute step 2)-5;
[0056] Step 2)-10: Determine whether mutation_level == model is true, if so, execute step 2)-11, otherwise execute step 2)-16;
[0057] Step 2)-11: Use OP and TT to train to get the original model origin_model;
[0058] Step 2)-12: Select the source-level mutation operator model_operator from MO;
[0059] Step 2)-13: Use model_operatot to mutate origin_model to obtain the mutated model mutation_model;
[0060] Step 2)-14: Add mutation_model to VM;
[0061] Step 2)-15: Determine whether the traversal of the model-level mutation operator is completed. If so, execute step 2)-16, otherwise execute step 2)-12;
[0062] Step 2)-16: Export VM;
[0063] Step 2)-17: End state.
[0064] Further, the specific steps of the above step 3) are as follows:
[0065] Step 3)-1: Starting state;
[0066] Step 3)-2: Input the variant model set VM, test set TS, original model origin_model, and precision threshold pre_threshold;
[0067] Step 3)-3: Initialize the total score of all variant models to total_score = 0;
[0068] Step 3)-4: Take out a mutation model mutation_model from VM;
[0069] Step 3)-5: Calculate the precision of mutation_model in TS pre_radio;
[0070] Step 3)-6: Determine whether pre_radio<pre_threshold is established, if so, execute step 3)-7, otherwise execute step 3)-18;
[0071] Step 3)-7: Initialize the number of detection classes class_number=0, k=0;
[0072] Step 3)-8: k++;
[0073] Step 3)-9: Take out the test set subset TS k ={t k,1 , t k,2 ,…,t k,m};
[0074] Step 3)-10: i=0;
[0075] Step 3)-11: i++;
[0076] Step 3)-12: Determine whether i<m is established, if so, execute step 3)-13, otherwise execute step 3)-15;
[0077] Step 3)-13: Judgment If yes, execute step 3)-14, otherwise execute step 3)-11;
[0078] Step 3)-14: class_number++;
[0079] Step 3)-15: Determine whether k>n-1 is established, if so, execute step 3)-16, otherwise execute step 3)-8;
[0080] Step 3)-16: Add the mutation score of mutation_model to total_score, which is calculated as follows:
[0081]
[0082] Execute steps 3)-18;
[0083] Step 3)-17: Delete mutation_model from VM;
[0084] Step 3)-18: Determine whether the mutation model in the VM has been traversed. If so, execute step 3)-19, otherwise execute step 3)-4;
[0085] Step 3)-19: Calculate the variation score, the calculation formula is as follows:
[0086]
[0087] Where size(MV) is the size of the variant model set MV;
[0088] Step 3)-20: Output mutation_score;
[0089] Step 3)-21: End state. BRIEF DESCRIPTION OF THE DRAWINGS
[0090] Figure 1 The present invention is a flowchart of a method for mutating an AI system software model oriented to neuron characteristics in the implementation of the present invention.
[0091] Figure 2 for Figure 1 Flowchart for automatic selection of mutation levels.
[0092] Figure 3 for Figure 1 Flowchart of the mutation model generation in .
[0093] Figure 4 for Figure 1 Flowchart of the variation score calculation. DETAILED DESCRIPTION
[0094] In order to better understand the technical content of the present invention, specific embodiments are given and described as follows in conjunction with the accompanying drawings.
[0095] Figure 1 The present invention is a flowchart of a method for mutating an AI system software model oriented to neuron characteristics implemented in the present invention.
[0096] A method for mutating an AI system software model based on neuron characteristics, characterized by comprising the following steps.
[0097] S1 mutation level is automatically selected. For each data subset of each category in the test set, the Euclidean distance is calculated and the distance matrix is used to save the distance between the two data. The minimum spanning tree of the data subset graph is calculated, and the weights in the tree are added to the set. Based on the values in the weight set, the distance entropy of each category is calculated, that is, the diversity of each class subset. According to the average distance entropy of the entire test set, the overall diversity of the test set is quantified, and the corresponding mutation level is automatically selected.
[0098] S2 mutation model generation, select the corresponding process according to the mutation level to generate multiple mutation models. For the source mutation level, use the source mutation operator to mutate the training program, then train the mutation training program with the training set, and add the trained mutation model to the mutation model set; for the model mutation level, use the original training program and the training set to train the original model, then use the model mutation operator to mutate the original model, and add the mutation model to the mutation program set.
[0099] S3 mutation score calculation, if the precision of the mutation model on the test set is too low, the mutation model will be deleted from the mutation model set. Using the n categories of the test set, observe the number of detection classes of each mutation model, calculate the total score of the test set on all mutation models, and find the average value, which is the mutation score of the final test set, effectively evaluating the quality of the test set.
[0100] Figure 2 Flowchart for automatic selection of mutation level. For each category sub-test set of the test set, the corresponding data matrix is calculated, the corresponding spanning tree is generated, and the distance entropy calculation is completed. The average value of the distance entropy of all categories is calculated to quantify the overall diversity of the test set, and the mutation level is automatically selected based on this. The specific steps are as follows:
[0101] Step 1: Starting state; Step 2: Input classification test set TS = {TS1, TS2, ..., TS n}, test set diversity threshold div_threshold; Step 3: Initialize the mutation level to the source level, denoted as mutation_level=source, test set diversity value div_value=0, k=1, execute step 5; Step -4: k++; Step 5: Take out the test set subset TS k ={t k,1 , t k,2 ,…,t k,m}; Step 6: Create a new m*m distance matrix matrix, i=1, j=1; Step 7: Calculate the distance matrix between the i-th and j-th data i,j and matrix j,i; Step 8: j++; Step 9: Determine whether j>m is true, if so, execute step 10, otherwise execute step 7; Step 10: i++, j=i+1; Step 11: Determine whether i>m-1 is true, if so, execute step 2, otherwise execute step 7; Step 12: Generate the minimum spanning tree tree of the matrix; Step 13: Generate the weight set W={w1,w2,…,w m-1}; Step 14: Calculate the weight of set W Step 15: Initialize distance entropy dis_ehtropy = 0; Step 16: Calculate the distance entropy of the weight set W Step 17: Add the average value of dis_entropy relative to all classes to div_value. Step 18: Determine whether k<n is established, if so, execute step 19, otherwise execute step 4; Step 19: Determine whether div_value<div_threshold is established, if so, execute step -20, otherwise execute step 21; Step 20: The mutation level is the model level, recorded as mutation_level=model; Step 21: Output mutation_level; Step 22: End state.
[0102] Figure 3 Flowchart for mutation model generation. Perform mutation operations on the corresponding mutation levels. Specifically, the source mutation level uses the source mutation operator to mutate the training program, and the mutation training program and the training set train the mutation model; the model mutation level uses the original training program and the training set to train the original model, and the model-level mutation operator is applied to the original model to generate the mutation model. The specific steps are as follows:
[0103] Step 1: Starting state; Step 2: Input training set TT, test set TS, original training program OP, mutation operator set MO, mutation level mutation_level; Step 3: Initialize mutation model set Step 4: Determine whether mutation_level == source is true, if so, execute step 5, otherwise execute step 10; Step 5: Select source-level mutation operator source_operator from MO; Step 6: Use source_operator to mutate OP to obtain mutation training program VP; Step 7: Use VP and TT to train to obtain mutation model mutation_model; Step 8: Add mutation_model to VM; Step 9: Determine whether the source-level mutation operator is traversed, if so, execute step 10, otherwise execute step 5; Step 10: Determine whether mutation_level == source is true, if so, execute step 10, otherwise execute step 5; = model is true, if so, execute step 11, otherwise execute step 16; step 11: use OP and TT to train to get the original model origin_model; step 12: select the source-level mutation operator model_operator from M0; step 13: use model_operator to mutate origin_model to get the mutation model mutation_model; step 14: add mutation_model to VM; step 15: determine whether the model-level mutation operator is traversed, if so, execute step 16, otherwise execute step 12; step 16: output VM; step -17: end state.
[0104] Figure 4 This is a flowchart for calculating the mutation score. With the mutation model set and the test set as input, observe which classes in the test set each mutation model can detect, and add up the proportion of the detection classes of each mutation model to find the average value, and finally get the mutation score of the test set, which effectively evaluates the quality of the test set. The specific steps are as follows:
[0105] Step 1: Starting state; Step 2: Input variant model set VM, test set TS, original model origin_model, precision threshold pre_threshold; Step 3: Initialize the total score of all variant models total_score = 0; Step 4: Take out a variant model mutation_model from VM; Step 5: Calculate the precision pre_radio of mutation_model in TS; Step 6: Determine whether pre_radio<pre_threshold is established, if so, execute step 7, otherwise execute step 18; Step 7: Initialize the number of detection classes class_number = 0, k = 0; Step 8: k++; Step 9: Take out the test set subset TS k ={t k,1 , t k,2 ,…,t k,m}; Step 10: i = 0; Step 11: i++; Step 12: Determine whether i < m is true, if so, execute step 13, otherwise execute step 15; Step 13: Determine If it holds, execute step 14, otherwise execute step 11; Step 14: class_number++; Step 15: Determine whether k>n-1 holds, if so, execute step 16, otherwise execute step 8; Step 16: Add the mutation score of mutation_model to total_score, and execute step 18; Step 17: Delete mutation_model from VM; Step 18: Determine whether the mutation model in VM has been traversed, if so, execute step 19, otherwise execute step 4; Step 19: Calculate the mutation score mutation_score; Step 20: Output mutation_score; Step 21: End state.
[0106] In summary, the present invention aims to solve the problem of quality assessment of deep learning system test sets. Using the variation score indicator can help software developers accurately evaluate the test set and ensure the quality of the deep learning system.
Claims
1. A method for AI system software model mutation based on neuron characteristics, characterized in that: First, the distance entropy distance_entropy of the data subset of each category in the test set is calculated, that is, the diversity degree of each class subset. According to the average distance entropy of the entire test set, the overall diversity degree div_value of the test set is quantified, and the corresponding mutation level mutation_level is automatically selected; on this basis, the mutation operator source_operator or model_operator of the corresponding level is selected, and multiple mutation models mutation_model are obtained by mutation; finally, the mutation models with low precision are screened out, and the mutation scores mutation_score of the remaining mutation models are calculated to effectively evaluate the quality of the test set; the method includes the following steps: 1) Automatic selection of mutation level: given a test set TS = {TS1, TS2, ..., TS n }; where each class subset TS k ={t k,1 , t k,2 ,…,t k,m }; Using Euclidean distance(t k,i , t k,j ) calculate and save TS using the distance matrix matrix k The distance between two pairs of data in the equation; the calculation formula of Euclidean distance is as follows: n represents the dimension of data x and y, calculate the minimum spanning tree tree of the distance matrix matrix, and add the weighted edges of tree to the set W, where W = {w1, w2, ..., w m-1 }; Calculate TS based on W k The distance entropy dis_entropy is calculated as follows: in, For n test subsets, the average value div_value of dis_ehtropy is calculated and compared with div_threshold to obtain the corresponding mutation level mutation_level; the calculation formula is as follows: The purpose of this step is to automatically select a mutation level suitable for the test set based on the diversity of the test set. Specifically, for a test set with a high degree of diversity, it is suitable to use model-level mutation testing. On the contrary, for a test set with a low degree of diversity, it is suitable to use source-level mutation testing. 2) Mutation model generation: select the corresponding process according to the mutation level mutation_level to generate multiple mutation models mutation_model; for the source mutation level source, use the source mutation operator source_operator to mutate the original training program OP, then train OP with the training set TT, and add the trained mutation model mutation_model to the mutation model set VM; for the model mutation level model, use OP and TT to train the original model origin_model, then use the model mutation operator model_operator to mutate origin_model, and add mutation_model to VM; 3) Mutation score calculation, given the precision threshold pre_threshold, the mutation model set VM and the test set TS = {TS1, TS2, ..., TS n }; First, if there is a mutation model mutation_model in VM and the precision pre_radio is lower than pre_threshold, mutation_model will be deleted from VM to eliminate the differences in the model caused by other reasons besides the introduction of mutation operators; then, if TS k There is data t k,i It is judged as TS on the original model origin_model k Class, but not judged as TS on mutation_model k class, then add 1 to the number of detection classes; finally, calculate the ratio of the number of detection classes of mutation_model to the number of all classes, and add them up to get the total score total_score. Use the size() function to calculate the total number of mutation models in VM size(VM), and find the average value of total_score, which is the final mutation score mutation_score of TS.
2. The AI system software model mutation method for neuron characteristics according to claim 1, characterized in that: In step 1), the mutation level is automatically selected. For each category of the data subset in the test set, the distance between the two data is calculated using the Euclidean distance and the distance matrix is used to save the distance; the minimum spanning tree of the data subset graph is calculated, and the weights in the tree are added to the set; Based on the values in the weight set, the distance entropy of each category, that is, the diversity of each class subset, is calculated. According to the average distance entropy of the entire test set, the overall diversity of the test set is quantified, and the corresponding mutation level is automatically selected.
3. The AI system software model mutation method for neuron characteristics according to claim 1, characterized in that: In step 2), mutation model generation is performed, and a plurality of mutation models are generated by selecting a corresponding process according to the mutation level; for the source-level mutation level, the source-level mutation operator is used to mutate the training program, and then the mutation training program and the training set are trained, and the trained mutation model is added to the mutation model set; for the model-level mutation level, the original model is trained using the original training program and the training set, and then the model-level mutation operator is used to mutate the original model, and the mutation model is added to the mutation program set.
4. The AI system software model mutation method for neuron characteristics according to claim 1, characterized in that: In step 3), the mutation score is calculated. If the precision of the mutation model on the test set is too low, the mutation model is deleted from the mutation model set. Using the n categories of the test set, the number of detection classes of each mutation model is observed, and the total score of the test set on all mutation models is calculated. The average value is obtained, which is the mutation score of the final test set, which effectively evaluates the quality of the test set.
