Multi-target black box test case selection method for deep neural network

By introducing a multi-objective black box test case selection method in the testing of deep neural networks, combining optimization strategies for the reduction phase and selection phase, the problems of test input diversity and computing resource limitations are solved, and efficient test input selection and powerful fault detection capabilities are achieved.

CN120162269APending Publication Date: 2025-06-17NANJING UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510357409.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-25
Publication Date
2025-06-17

AI Technical Summary

Technical Problem

During the testing of deep neural networks, the existing technology is difficult to effectively solve the problems of diversity of test inputs and limitation of computing resources, resulting in low test selection efficiency and insufficient fault detection capabilities.

Method used

A multi-objective black box test case selection method for deep neural networks is proposed. Through the combination of reduction phase and selection phase, dynamic reduction coefficients and a rapid screening mechanism based on uncertainty are introduced, and an isometric division strategy and greedy selection mechanism are adopted to optimize uncertainty and diversity.

Benefits of technology

Significantly reduces computational overhead, improves the efficiency of test input selection, and ensures that the selected test set can cover more variety of faults, thereby improving the value of fault detection capabilities and model optimization guidance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120162269A_ABST
    Figure CN120162269A_ABST
Patent Text Reader

Abstract

The invention discloses a multi-target black-box test case selection method for a deep neural network, which comprises multi-target optimization, search space reduction and equidistant partition optimization, and aims to improve the test efficiency by optimizing two targets of uncertainty and diversity under a given test budget. According to the method, test inputs capable of detecting different errors of the model are selected as many as possible for the test of the deep neural network, the uncertainty of the DNN model to the test inputs is evaluated, and only the test inputs with high uncertainty in an original test set are reserved as candidate sets; in the subsequent selection, the candidate set is divided into subgroups which are equal in size and similar in uncertainty distribution by adopting an equidistant partition division mode, then an optimal test input is iteratively selected from each subgroup by utilizing a greedy strategy, and the selected input not only has relatively high error triggering capability, but also has relatively high reliability. The diversity of the selected test input can be greatly improved; and the method has the characteristics of high selection efficiency and high error detection capability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of software testing, and is mainly applied to the testing field of deep neural networks. Specifically, it relates to a multi-objective black-box test case selection method for deep neural networks. Background Art

[0002] In the actual testing process of DNN, two key challenges are faced: First, in order to comprehensively evaluate the model performance, a large number of test inputs need to be collected to detect the performance of the model in different scenarios. However, manually annotating these test inputs requires a large amount of time and resources. Second, in some specific application scenarios, due to the limitation of computing resources, the number of actually executable test inputs is often strictly limited. Currently, DNN test selection methods are mainly divided into two categories: white-box methods and black-box methods. White-box methods guide test selection by analyzing indicators such as neuron coverage, conducting mutation testing, or evaluating model surprise. Black-box methods rely only on the output results of the model or the characteristics of the test inputs themselves for selection, and have better applicability.

[0003] Early black-box methods were mainly based on the concept of "uncertainty". Although a large number of studies have confirmed the effectiveness of uncertainty-based selection methods in triggering error predictions, such methods have a significant defect: overemphasizing uncertainty and ignoring the diversity of test inputs, which may lead to redundancy in the selected test set and cannot fully cover various failure modes of DNN. To overcome the above limitations, the prior art DeepGD achieves more effective test selection by simultaneously optimizing two key objectives: uncertainty and diversity. However, this method has an obvious performance bottleneck: the non-dominated sorting genetic algorithm (NSGA-II) it uses has a high computational complexity, and the computational cost of the diversity metric is also quite large, resulting in an overall excessive computational overhead. This high computational cost severely limits the application feasibility of DeepGD on large-scale data sets. Summary of the Invention

[0004] The purpose of the present invention is to provide a multi-objective black-box test case selection method for deep neural networks to solve the problems raised in the above background art.

[0005] To solve the above technical problems, the present invention provides the following technical solution: A multi-objective black-box test case selection method for deep neural networks, including a reduction stage and a selection stage. The reduction stage is used to screen out candidate test inputs with higher uncertainty from the original test input set, introducing a dynamic reduction coefficient and a fast screening mechanism based on uncertainty. The selection stage is used to select a subset from the candidate set by simultaneously optimizing uncertainty and diversity, an equidistant partitioning strategy, and a greedy selection mechanism. Preferably, the specific operation steps of the reduction stage are as follows: : Run all test inputs on the model to be tested and obtain the corresponding output probabilities; : Select an uncertainty metric to construct an uncertainty calculation function ; : Calculate the uncertainty values of all test inputs; : Sort the test inputs according to the uncertainty values; : Set a reduction coefficient ; : Determine the candidate set .

[0006] Preferably, the specific operation steps of the selection stage are as follows: : Equally partition the candidate set ; : Select a diversity metric to construct a diversity value calculation function ; : Extract the features of the test inputs; : Calculate the diversity gain of the candidate test inputs with respect to the selected test input set as their diversity values; : Calculate the fitness values of the candidate test inputs; : Iteratively select the optimal test inputs in each subgroup; : Return the finally selected subset of test inputs at the end of the iteration , for manual annotation for DNN testing.

[0007] Compared with the prior art, the beneficial effects achieved by the present invention are: (1) Through effective test input reduction and equal-distance partitioning optimization of the candidate set, the present invention significantly reduces the computational overhead and can complete the selection of test inputs in a shorter time; (2) During the test input selection process, the present invention optimizes both uncertainty and diversity, and designs a new evaluation mechanism to ensure that the selected test set can cover more diverse faults, thereby maintaining a high fault detection ability while improving efficiency; (3) The test inputs selected in the present invention have higher representativeness and information content, and can provide more valuable guidance for the retraining of the model. In summary, the present invention has achieved significant improvements in test efficiency, fault detection ability, and model optimization guidance, providing a more efficient and reliable solution for the testing and optimization of deep neural networks. BRIEF DESCRIPTION OF THE DRAWINGS

[0008] The drawings are used to provide a further understanding of the present invention and constitute a part of the specification. They are used together with the embodiments of the present invention to explain the present invention and do not constitute a limitation to the present invention. In the drawings: Figure 1 is the pseudo-code of the algorithm implementation provided by the embodiment of the present invention; Figure 2 is an example diagram of the overall process provided by the embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0009] To further elaborate on the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the following, in conjunction with the drawings and preferred embodiments, details the specific implementation manners, structures, features, and their effects according to the present invention as follows.

[0010] The embodiment of the present invention combines Figure 1 with Figure 2 to provide the following technical solution: A multi-objective black-box test case selection method for deep neural networks, including a reduction stage and a selection stage In this embodiment, Figure 1 the pseudo-code shown demonstrates the detailed process of the present invention. Compared with the prior art, the core innovation of the present invention is that through a phased optimization strategy, the computational overhead is significantly reduced, while ensuring the uncertainty and diversity of the selected test inputs, so that it still maintains a high fault detection ability; In this embodiment, the reduction stage is Figure 1 shown in lines 3-6. The goal of the reduction stage is to screen out candidate test inputs with higher uncertainty from the original test input set to reduce the search space for subsequent selection. Compared with the prior art, the innovation of this stage is the introduction of a dynamic reduction coefficient and a fast screening mechanism based on uncertainty, which can significantly reduce the computational complexity of subsequent selection while ensuring the screening effect; Exemplarily, the specific running steps of the reduction stage are as follows: : Run all test inputs on the model to be tested to obtain the corresponding output probabilities; Exemplarily, given a set of original test input sets and a test budget , execute all test inputs on the DNN model to be tested once, and obtain the model for each test input Predicted output probability , in the form of , where is the total number of labels, is the probability that the model under test believes belongs to the th label, and , this step only depends on the output probability of the model and does not require accessing the internal structure of the DNN model or the training set data, and is applicable to the black-box testing scenario.

[0011] : Select an uncertainty metric to construct an uncertainty calculation function ; Exemplarily, the present invention can use any existing uncertainty metric to construct a function , and the user can select a suitable metric according to their actual needs to construct an uncertainty calculation function , the default uncertainty metric of the present invention is Maxp, and the Maxp metric takes the maximum value of the output probability (i.e., ) as the confidence of the model for the test input. The higher its value, the more certain the output of the model for the test input. Accordingly, an uncertainty calculation function can be constructed.

[0012] : Calculate the uncertainty values of all test inputs; Exemplarily, according to the output probability obtained in step , and the uncertainty calculation function constructed in step , calculate the uncertainty value of each test output . That is, the uncertainty metrics are all designed based on the output probability of the model. The higher the uncertainty value, the greater the possibility that the test input triggers an incorrect prediction, and vice versa.

[0013] : Sort the test inputs according to the uncertainty values; Exemplarily, according to the calculated uncertainty values, sort all test inputs in descending order to obtain an ordered set , where represents the test input with the th highest uncertainty value. This step quickly locates high-uncertainty test inputs through sorting, providing a basis for subsequent screening.

[0014] : Set a reduction coefficient ; Exemplarily, the present invention introduces a reduction coefficient Dynamically adjust the size of the candidate set in the selection stage and set the candidate set to be , so that the size of the candidate set can be dynamically adjusted, and it can be ensured that the search space changes dynamically with the test budget . This not only avoids the computational overhead caused by an overly large search space but also ensures the diversity of the candidate set. It should be noted that although it can be set according to the needs of the user, it cannot be too small or too large. If it is too small, such as , then the size of the candidate set is the same as the size of the test budget, and the next selection cannot be carried out; if it is too large, the efficiency improvement brought by reducing the test set will be weakened. The default value of the present invention is 3

[0015] : Determine the candidate set ; Exemplarily, according to the reduction coefficient set in step , calculate the size of the candidate set , and select the first test inputs from the ordered test set to form the candidate set

[0016] Through the above steps, the reduction stage significantly reduces the search space in the subsequent selection stage while retaining the key test inputs that may trigger error predictions In this embodiment, the selection stage is as shown in Figure 1 Figures 9-15. The goal of the selection stage is to select a subset from the candidate set by simultaneously optimizing uncertainty and diversity, that is, improving the ability to trigger error predictions and ensuring that the triggered error predictions are caused by different root faults. The innovation of this stage lies in the equidistant partitioning strategy and the efficient greedy selection mechanism, which can ensure the effect of multi-objective optimization while significantly reducing the number of fitness calculations; Exemplarily, the specific running steps of the selection stage are as follows: : Equidistantly partition the candidate set ; Exemplarily, the present invention uses the equidistant partitioning method to evenly partition the candidate set into subgroups , where each subgroup and contains test inputs. The present invention takes into account the candidate set ​It has been sorted by uncertainty values, so equidistant partitioning is used to divide into subgroups, making the uncertainty distribution of each subgroup close to the overall distribution, avoiding over-concentration or dispersion of test inputs in terms of uncertainty levels.

[0017] : Select a diversity metric to construct a diversity value calculation function ; Exemplarily, the present invention can use any existing diversity metric to construct a function , and the user can select a suitable metric according to their actual needs to construct a diversity value calculation function . The default diversity metric of the present invention is Geometric Diversity (GD). The GD metric evaluates the diversity of a set through the determinant of the feature matrix of the test inputs within the set. Based on this, a diversity calculation function can be constructed , where represents the determinant, represents the feature matrix of a given set , and each row of the matrix represents the -dimensional feature vector of the corresponding test input, represents the transpose of.

[0018] : Extract the features of the test inputs; Exemplarily, this step is an optional step, determined according to the calculation requirements of the selected diversity metric. If the default option of the present invention is used, this step cannot be omitted. That is, the default diversity metric GD of the present invention requires obtaining the feature representation of the test inputs. The user can select a suitable feature extraction model to obtain the feature representation of the test inputs. The present invention defaults to using the VGG16 model to obtain the feature representation of the test inputs.

[0019] : Calculate the diversity gain of the candidate test input with respect to the selected set of test inputs as its diversity value; Exemplarily, since the diversity value function can only calculate the diversity of a set, the present invention innovatively proposes to calculate the diversity value of a test input by comparing the difference in diversity before and after adding a certain test input to the set , and the calculation is as follows: .

[0020] : Calculate the fitness value of the candidate test input; Exemplarily, the uncertainty value of the test input has been calculated in the reduction phase, and how to test the diversity value of the test input is also specified in step , and then the fitness value of the test input can be calculated for the evaluation of subsequent selection, and its calculation is as follows: where is the min-max normalization function, which is used to limit the diversity value within the range of [0, 1], making it of the same order of magnitude as the uncertainty value, and avoiding the fitness evaluation deviation caused by different orders of magnitude. The fitness value comprehensively considers uncertainty and diversity, and the larger the value, the better the test input. Another innovation point of this step is to combine uncertainty and diversity through multiplication to avoid selecting test inputs that perform poorly on any index.

[0021] : Iteratively select the optimal test input in each subgroup; Exemplarily, traverse the divided subgroups in order (that is, a total of iterations), each iteration only processes one subgroup, traverse all test inputs within the current subgroup, calculate the corresponding fitness value according to the fitness value function defined in step , and select the test input with the maximum fitness value and put it into the final subset . This step realizes efficient selection through the greedy strategy. Due to the partitioning operation in step , the number of fitness calculations in the selection process is significantly reduced, greatly improving the efficiency.

[0022] : Return the finally selected subset of test inputs at the end of the iteration for manual annotation for DNN testing.

[0023] Exemplarily, after the selection is completed, the finally selected subset of test inputs is obtained. This subset not only contains test inputs with relatively high uncertainty values but also has good diversity, which can trigger more different types of faults, thus helping to test the performance of the deep neural network model as comprehensively as possible within the test budget. Finally, these test inputs are manually annotated to form test cases for DNN model testing.

[0024] In this embodiment, as shown in combination with Figure 2 , an example is used to show the overall workflow of the present invention. In this example, the present invention attempts to select a subset from the original test set ( ) , the test budget is ; Specifically, in the reduction phase, the present invention first executes All test inputs in get their output probabilities, and then, according to The uncertainty values ​​calculated by the function are sorted in descending order to obtain the ordered set ,in Indicates the uncertainty value A high test input corresponds to Figure 2 (1), where the present invention uses the default reduction factor , so the present invention selects the first 6 ( ),like Figure 2 As shown in (2), the test input forms a candidate set ; Specifically, in the selection stage, Figure 2 As shown in (3), the present invention converts the ordered candidate set Divided into two subgroups by equal distance division: and ; Through this division, each subgroup contains test inputs with different uncertainty levels, and their uncertainty distribution is similar to The distribution of is close; finally, the present invention uses a greedy strategy to select from each subgroup and Iteratively select the test input with the highest fitness value and add it to Figure 2 (4) The subset shown middle; Furthermore, the final selected subset Not only does it have higher diversity, it also contains test inputs with higher uncertainty values, which can trigger more false predictions and reveal a wider range of unique failures in the model.

[0025] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any form. Although the present invention has been disclosed as a preferred embodiment as above, it is not used to limit the present invention. Any technical personnel in this field can make some changes or modify the technical contents disclosed above into equivalent embodiments without departing from the scope of the technical solution of the present invention. However, any brief modifications, equivalent changes and modifications made to the above embodiments based on the technical essence of the present invention without departing from the content of the technical solution of the present invention are still within the scope of the technical solution of the present invention.

Claims

1. A multi-objective black-box test case selection method for deep neural networks, characterized by: The method includes a reduction phase and a selection phase. The reduction phase is used to screen out candidate test inputs with higher uncertainty from the original test input set, and introduces a dynamic reduction coefficient and a fast screening mechanism based on uncertainty. The selection phase is used to select a subset from the candidate set by simultaneously optimizing uncertainty and diversity, an equidistant partitioning strategy and a greedy selection mechanism.

2. A multi-objective black-box test case selection method for deep neural networks according to claim 1, characterized in that: The specific operation steps of the reduction phase are as follows: : Run all test inputs on the model to be tested to obtain the corresponding output probabilities, which are output probabilities that depend only on the model without accessing the internal structure of the DNN model or the training set data; : Select uncertainty index to construct uncertainty calculation function ; : Calculate the uncertainty value of all test inputs; : Sort the test inputs according to the uncertainty value; : Set the reduction factor ; :Determine the candidate set .

3. The method for selecting multi-objective black-box test cases for deep neural networks according to claim 2, characterized in that: The obtaining of the corresponding output probability specifically includes: given a set of original test input sets and test budget , execute all test inputs on the DNN model to be tested, and obtain the model for each test input Predicted output probability , ,in is the total number of labels, For the model to be tested Belong to The probability of a label, and .

4. The method for selecting multi-objective black-box test cases for deep neural networks according to claim 2, characterized in that: The construction of the uncertainty calculation function includes: using an uncertainty indicator constructor , the uncertainty index is an arbitrary uncertainty index, and the arbitrary uncertainty index includes Maxp, and the Maxp index will output the maximum value of the probability, that is, As the confidence of the model for the test input, the higher the value, the more certain the model's output for the test input is, and the uncertainty calculation function is constructed. , .

5. The method for selecting multi-objective black-box test cases for deep neural networks according to claim 2, characterized in that: The calculation of the uncertainty values ​​of all test inputs includes: according to the output probability and the uncertainty calculation function , calculate each test output The higher the uncertainty value, the more likely the test input is to trigger an incorrect prediction; The method of sorting the test inputs according to the uncertainty value includes: sorting all the test inputs in descending order according to the calculated uncertainty value to obtain an ordered set ,in Indicates the uncertainty value High test input; The setting reduction factor Including: Introducing reduction factors Dynamically adjust the size of the candidate set in the selection phase and set the candidate set The size is ; The determined candidate set Including: according to the reduction factor , calculate the candidate set Size , the ordered test set The front Test inputs are selected to form a candidate set .

6. The method for selecting multi-objective black-box test cases for deep neural networks according to claim 1, characterized in that: The specific operation steps of the selection stage are as follows: : Equally spaced candidate sets ; : Select diversity indicators to construct diversity value calculation function ; : Extract features of test input; : Compute candidate test inputs for the selected test input set The diversity gain of is taken as its diversity value; : Fitness value calculation of candidate test input; : Iteratively select the best test input in each subgroup; : Return the final selected test input subset at the end of the iteration , manual annotation is performed for DNN testing.

7. The method for selecting multi-objective black-box test cases for deep neural networks according to claim 6, characterized in that: The equal distance partition candidate set Including: Using equal distance partitioning method to divide the candidate set Divide evenly into Subgroup , where each subgroup and Include Test inputs; The diversity index is selected to construct a diversity value calculation function Includes: Using diversity indicator constructor , the diversity index is an arbitrary diversity index, the arbitrary diversity index includes the GD index, the GD index evaluates the diversity of the set through the determinant of the characteristic matrix of the test input in the set, and constructs a diversity calculation function ,in represents the determinant, Represents a given set The feature matrix of each row of the matrix represents the corresponding test input dimensional feature vector, represent The transpose of .

8. The method for selecting multi-objective black-box test cases for deep neural networks according to claim 6, characterized in that: The extraction of test input features is an optional step, which is determined according to the calculation requirements of the selected diversity index.

9. The method for selecting multi-objective black-box test cases for deep neural networks according to claim 6, characterized in that: The fitness value calculation includes: calculating the test input The fitness value of The evaluation used for subsequent selection is calculated as follows: ,in, is a minimum-maximum normalization function that limits the diversity value to the range [0, 1] so that it is in the same order of magnitude as the uncertainty value, while combining uncertainty and diversity through multiplication.

10. The method for selecting multi-objective black-box test cases for deep neural networks according to claim 6, characterized in that: The iterative selection of the optimal test input in each subgroup includes: traversing the divided subgroups in order: Each iteration processes only one subgroup, traverses all test inputs in the current subgroup, calculates the corresponding fitness value according to the fitness value function, and selects the test input with the maximum fitness value to be put into the final subset. middle.