Deep learning test sample ranking method combining data distribution and graph analysis
By combining data distribution and graph analysis methods, and using variational autoencoders and neuron activation graphs to generate sample scores, the problem of insufficient utilization of model parameters and decision process information in deep learning test sample ranking is solved, achieving more efficient and accurate sample ranking.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING INST OF TECH
- Filing Date
- 2023-05-06
- Publication Date
- 2026-07-21
AI Technical Summary
Existing deep learning test sample ranking methods lack full utilization of model parameters and decision-making process information, resulting in poor ranking quality and a tendency to select samples that do not fit the model task, leading to meaningless testing, slow efficiency, and unstable performance.
By using variational autoencoders to calculate the LikelihoodRegret score of samples to filter out samples that do not meet the model task, the transition matrix and adjacency matrix of the neuron activation map of the sub-model are generated. The XGBoost and lightGBM models are then combined for geometric weighted fusion to generate sample scores to guide the ranking.
It improves the quality and efficiency of sample sorting, accurately locates model defect sites, and enhances the detection efficiency of test sample sequences.
Smart Images

Figure CN116933048B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a deep learning test sample ranking method that combines data distribution and graph analysis, and belongs to the field of computer and information science. Background Technology
[0002] Testing deep learning models is crucial for ensuring their reliability and security. Unlike traditional software, deep learning model construction is data-driven; therefore, testing requires inputting test samples and validating them using expected results. Determining the expected results of these test samples is a significant challenge. When testers collect large amounts of real-world data to test models, the lack of effective automated annotation techniques often necessitates manual annotation. Furthermore, the real-world datasets used for testing are typically massive, leading to high labor costs. Therefore, researching test sample ranking methods can utilize a small subset of high-quality test samples from the original data to replace large-scale datasets, thereby quickly exposing model defects and reducing the number of manually annotated samples. This has significant theoretical and practical value for improving the efficiency and reducing the cost of deep learning model testing.
[0003] The core problem that test sample ranking methods need to solve is how to define samples that are more valuable or of higher quality for testing. Existing cutting-edge methods mainly include the following four categories:
[0004] 1. Coverage-based methods
[0005] Coverage-based methods rank samples by maximizing the activation of DNN neurons (such as DeepGauge). However, the neuron coverage metric is not directly related to the sufficiency of deep learning model testing, lacks utilization of model structure and decision-making process information, and the ranking quality is insufficient. Furthermore, subsequent studies have shown that the performance of such methods is sometimes not better than random selection.
[0006] 2. Uncertainty-based methods
[0007] Uncertainty-based methods rank samples by calculating the confidence level of the deep learning model on the test samples (such as DeepGini). Since they only focus on the model output of a single test and only utilize the information of the output layer, they often perform well only in simple scenarios. Their performance drops significantly on large datasets and complex model structures. Furthermore, their computational method is singular, their scalability is poor, and it is difficult to continuously optimize performance by adding or updating rules.
[0008] 3. Surprise sufficiency-based approach
[0009] Surprise sufficiency-based methods rank samples by measuring how surprised the model is to the test samples (such as LSA and DSA). Because they only pursue maximizing sample differences, they ignore the judgment of the model task and the impact on the improvement of model capabilities. They may include a large number of samples that cannot be labeled in reality or have no correct labels at all in the selected test samples, resulting in meaningless testing.
[0010] 4. Methods based on mutation analysis
[0011] Methods based on mutation analysis rank samples by measuring the degree of change in predicted results before and after a mutation (e.g., PRIMA). However, these methods are time-consuming to run mutation operators, and this time cost increases further with the number of mutation operators. Furthermore, the impact of mutations is amplified in models with more layers, exacerbating the randomness problem in the testing process.
[0012] In summary, existing deep learning test sample priority ranking methods have the following main problems: (1) They lack full utilization of model parameters and decision process information, resulting in poor ranking quality; (2) They lack a filtering mechanism for test samples, making it easy to select unlabeled samples that do not conform to the model task, leading to meaningless testing; (3) The impact of the test is transmitted in the model, which is greatly affected by the data scale and model complexity, resulting in slow sample ranking efficiency and unstable performance. Summary of the Invention
[0013] The purpose of this invention is to address the problems of existing deep learning test sample ranking methods lacking a filtering mechanism for samples that match the model task and lacking full utilization of model parameters. This invention proposes a deep learning test sample ranking method that combines data distribution and graph analysis.
[0014] The design principle of this invention is as follows: First, a variational autoencoder (VAE) is used to calculate the LikelihoodRegret (LR) score of the sample for out-of-distribution detection, filtering out test samples that do not conform to the model task; second, each hidden layer in the original model is fully connected to generate a sub-model from the output layer, and a transition matrix is generated based on the predicted probability of the sample in each sub-model; then, the activation values of the model neurons are captured, arranged in order to construct a neuron activation map, and their adjacency matrix is extracted; finally, the transition matrix and adjacency matrix are concatenated as sample features to train XGBoost (Xgb) and lightGBM (Lgb) models, and the outputs of the two models are geometrically weighted and fused to obtain the test sample score. The test sample score is used to guide the sorting of samples in the unlabeled test sample set to obtain the sample sequence.
[0015] The technical solution of the present invention is achieved through the following steps:
[0016] Step 1: Calculate the LR score of the samples and filter out samples that do not conform to the model task.
[0017] Step 1.1: Train the VAE using the test sample set.
[0018] Step 1.2: Calculate the LR score of the test sample based on the VAE's estimate of the test sample.
[0019] Step 1.3: Filter test samples that exceed the threshold based on LR scores.
[0020] Step 2: Generate a sub-model and generate a transition matrix based on the predicted probabilities of the samples by the sub-model.
[0021] Step 2.1: Each hidden layer in the original model is fully connected to generate a sub-model from its output layer.
[0022] Step 2.2: Input the test samples into the sub-model in the order generated in Step 2.1 to obtain the predicted probability vector output by the sub-model.
[0023] Step 2.3: Concatenate the probability vectors output in step 2.2 to generate the transition matrix.
[0024] Step 3: Capture the neuron activation map of the original model for the sample and extract its adjacency matrix.
[0025] Step 3.1: Extract the original DNN model into an undirected weighted graph.
[0026] Step 3.2: Map the activation values of neurons after inputting the test samples into the model onto the graph obtained in Step 3.1 to generate a neuron activation map.
[0027] Step 3.3: Extract the adjacency matrix of the generated neuron activation map.
[0028] Step 4: Combine the transition matrix obtained in step 2.3 and the adjacency matrix obtained in step 3.3 as sample features.
[0029] Step 5: Train the Xgb and Lgb models using the sample features integrated in Step 4, and geometrically weight the outputs of the two models to the samples, which will be used as test sample scores to guide sample ranking.
[0030] Step 5.1: Compare the prediction results of the known test samples in the original model with the true labels to obtain the binary classification labels of whether the classification is incorrect.
[0031] Step 5.2: Train the Xgb and Lgb models using the sample features obtained in step 4 and the binary classification labels obtained in step 5.1, respectively, based on the known test samples.
[0032] Step 5.3: Repeat steps 1 to 4 with unlabeled test samples to be sorted, and input the obtained sample features into the two models.
[0033] Step 5.4: The output of the two geometrically weighted models on the unlabeled test samples is used as the sample score.
[0034] Step 5.5: Based on the test sample scores in Step 5.4, sort the unlabeled test samples from high to low to obtain the sample sequence.
[0035] Beneficial effects
[0036] Compared to existing deep learning test sample priority ranking methods, this invention can utilize a data distribution-based detection mechanism to reduce data in test samples that do not conform to the model task, thus ensuring the effectiveness of the testing work. By utilizing the neuron activation map and the predicted probability changes of sub-models, it fully utilizes the model's structure and parameter information, as well as the dynamic characteristics of the model's decision-making process, effectively improving the ranking quality while more accurately locating defective sites in the model, thereby improving the efficiency of detecting model errors in test sample sequences. Attached Figure Description
[0037] Figure 1 This is a schematic diagram illustrating the principle of the deep learning test sample ranking method that combines data distribution and graph analysis according to the present invention. Detailed Implementation
[0038] To better illustrate the purpose and advantages of the present invention, the implementation methods of the present invention will be further described in detail below with reference to examples.
[0039] The experimental data are based on three open-source image datasets: MNIST, Fashion-MNIST, and SVHN. Detailed descriptions are provided in Table 1. For each dataset, 30,000 samples were selected as known test samples to train the model, while the remaining samples were used as unlabeled, unsorted samples for testing.
[0040] • Detailed description of the dataset used in Table 1
[0041]
[0042] The experiment used time and the RAUC-all index to evaluate the performance of the method. The specific calculation method is as follows:
[0043] (1) Time. In the experiment, time is defined as the time interval from the input of the samples to be sorted into the distribution detection module to the output of the sorting sequence of the samples by the sorting model, in seconds (s).
[0044] (2) RAUC-all. The number of tested samples is plotted on the horizontal axis, and the number of samples triggering model classification errors is plotted on the vertical axis. All unsorted samples are sorted and then input into the model for testing. The ratio of the area under the curve to the area under the curve in the ideal case is denoted as RAUC-all, as shown in formula (1):
[0045]
[0046] Where n represents the total number of samples to be sorted, m represents the number of samples that will trigger a classification error in the model, and y a This represents the true label of the sample. This represents the model's prediction results. The RAUC-all index reflects the efficiency with which the sample sequence triggers erroneous behavior in the model, and its value ranges from [0,1].
[0047] This experiment was conducted on a computer and a GPU server. The computer was configured with an Intel(R) Core(TM) i7-6700 CPU with a clock speed of 3.40GHz, 8GB RAM, and a 64-bit Windows 10 operating system. The server was configured with a GTX1080 Ti GPU with 256GB RAM and a 64-bit Linux Ubuntu operating system.
[0048] The specific process is as follows:
[0049] Step 1: Calculate the LR score of the samples and filter out samples that do not conform to the model task.
[0050] Step 1.1: The VAE uses variational inference to derive the lower bound of the log likelihood of the observed sample x, i.e., the lower bound of evidence (ELBO), as shown in Equation (2). The test sample set is input into the VAE, and the VAE is trained by maximizing L(x; η, Φ).
[0051]
[0052] Where q Φ (z|x) is the true posterior distribution p θ Variational approximation of (z|x), q Φ (z|x) and p η (x|z) are the results of parameterization of the neural network with parameters Φ (encoder) and η (decoder), respectively.
[0053] Step 1.2: Since VAE only outputs the lower bound of the log-likelihood of sample x, it is necessary to estimate the accurate log-likelihood using the importance-weighted lower bound, as shown in formula (3), where z k It comes from variational posterior q ΦFor the sample of (z|x), since the inequality in formula (3) asymptotically approximates the value of K as K increases, we set K = 10000 in the experiment. At this time, L K (x;η,Φ) is a good estimate of the exact log-likelihood of the sample.
[0054]
[0055] The LR score of the sample is calculated as shown in formula (4), where Φ * These are the initial encoder parameters, Φ is the encoder parameter obtained by maximizing the ELBO objective, and η is the encoder parameter. * These are the optimal decoder parameters obtained from the training set.
[0056] L VAE =L K (x;η * ,Φ * )
[0057] L opt =L K (x;η * ,Φ)
[0058] LR=L opt -L VAE (4)
[0059] Step 1.3: Select a judgment threshold through experiments. If the LR score of a sample exceeds the threshold, remove the sample from the set of unlabeled test samples to be sorted.
[0060] Step 2: Generate a sub-model and generate a transition matrix based on the predicted probabilities of the samples by the sub-model.
[0061] Step 2.1: Suppose that the DNN model to be tested contains K hidden layers. Keep the i-th hidden layer (1≤i≤K) and the hidden layers before it, and delete the hidden layers after it. Connect the i-th layer directly to the output layer to obtain the i-th sub-model. Extract a total of K sub-models in order.
[0062] Step 2.2: Using the sub-models generated in Step 2.1, input the test samples sequentially from the first sub-model to the Kth sub-model to obtain the classification prediction probability vector output by each sub-model.
[0063] Step 2.3: Based on the change process of the classification prediction probability vector output in Step 2.2, the vectors are concatenated to obtain the transition matrix from sub-model 1 to sub-model K.
[0064] Step 3: Capture the neuron activation map of the original model for the sample and extract its adjacency matrix.
[0065] Step 3.1: Treat the neurons of the DNN model as nodes and the weights of the model as weighted edges between nodes to obtain the undirected weighted graph representation of the model.
[0066] Step 3.2: Based on the neuron activation status after the sample input to the DNN model, only the activation part of the graph in step 3.1 is retained. The weights of the edges are modified according to the neuron output, as shown in formula (5), and directions are added to the edges of the graph to generate a directed weighted graph as the neuron activation graph.
[0067]
[0068]
[0069] Where D = (V, E) is a directed weighted graph, with node set V, edge set E, and A being the adjacency matrix of D. i w is the i-th node of D j,i It is v j and v i The weights between them.
[0070] Step 3.3: Based on step 3.2 and formula (5), extract the adjacency matrix A of the generated activation graph.
[0071] Step 4: Combine the transition matrix obtained in step 2.3 and the adjacency matrix obtained in step 3.3 as sample features.
[0072] Step 5: Train the Xgb and Lgb models using the sample features integrated in Step 4, and geometrically weight the outputs of the two models to the samples, which will be used as test sample scores to guide sample ranking.
[0073] Step 5.1: Input the known test sample into the original model, compare the model's prediction results with the true labels, and obtain the binary classification label based on whether the sample causes the model's decision error. The specific calculation method of the label is shown in formula (6), where y is the binary classification label of the sample used to train the ranking model. i For the true label of the sample, This represents the prediction results of the sample on the DNN model.
[0074]
[0075] Step 5.2: Use known test samples to complete steps 1 to 4. Use the sample features obtained in step 4 and the binary classification labels obtained in step 5.1 to train the Xgb and Lgb models respectively.
[0076] Step 5.3: Repeat steps 1-4 using unlabeled test samples to be sorted, and input the obtained sample features into the two models.
[0077] Step 5.4: Geometrically weighted fusion of the outputs of the two models on the unlabeled test samples as the test sample score. The weighted fusion calculation method is shown in formula (7).
[0078] Score = xgb α *lgb 1-α (7)
[0079] Where Score is the test sample score, xgb and lgb represent the output scores of the two models for the test sample, and α is a set hyperparameter that is tuned through experiments.
[0080] Step 5.5: Based on the test sample scores in Step 5.4, sort the unlabeled test samples from high to low to obtain the sample sequence.
[0081] This invention specifically describes a deep learning test sample ranking method that combines data distribution and graph analysis. Based on three open-source image datasets, it tests image classification models. Compared with the most advanced existing methods, this invention achieves the best ranking performance on the RAUC-all metric, improves the ranking computation time compared to the PRIMA method, and has the best overall performance. Furthermore, compared with all existing methods, it fully utilizes the white-box structure and parameter information of the model, as well as the dynamic features of the model's decision-making process through graph analysis, which helps to more accurately locate the defective sites of the model when model errors are triggered.
[0082] The above detailed description further illustrates the purpose, technical solution, and beneficial effects of the invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A deep learning test sample ranking method combining data distribution and graph analysis, characterized in that... The method includes the following steps: Step 1: Train the variational autoencoder, calculate the LikelyhoodRegret score of the test sample based on the estimated value of the test sample, perform threshold comparison, and filter out test samples in the test sample set that do not conform to the model task. The test sample set is an image. Step 2: Generate sub-models by fully connecting the output layers of each hidden layer of the model, and concatenate the prediction probability vectors of each sub-model for the test samples in order to generate the transition matrix; Step 2 includes: Step 2.1: Suppose the DNN model to be tested contains K hidden layers. Keep the i-th hidden layer and all hidden layers before it, and delete the hidden layers after it. Connect the i-th layer directly to the output layer to obtain the i-th sub-model. Extract a total of K sub-models in order, where 1≤i≤K. Step 2.2: Using the sub-models generated in Step 2.1, input the test samples sequentially from the first sub-model to the Kth sub-model to obtain the classification prediction probability vector output by each sub-model. Step 2.3: Based on the change process of the classification prediction probability vector output in Step 2.2, the vectors are concatenated to obtain the transition matrix from sub-model 1 to sub-model K; Step 3: Capture the activation values of neurons in the model for the test samples, arrange and construct the neuron activation map and extract its adjacency matrix; Step 4: Combine the transition matrix obtained in Step 2 and the adjacency matrix obtained in Step 3 as sample features; Step 5: Use the sample features obtained in Step 4 to train XGBoost and LightGBM models and geometrically weight the outputs of the two models on the samples, and use the test sample scores to guide the sample ranking.
2. The deep learning test sample ranking method combining data distribution and graph analysis according to claim 1, characterized in that: In step 1, the Likelyhood Regret score of the test samples is calculated using the estimate of the variational autoencoder, and test samples that do not conform to the model task are filtered out. This introduces an input validation and filtering mechanism for deep learning testing, reduces the impact of out-of-distribution samples in naturally collected data on model testing, and avoids generating meaningless tests.
3. The deep learning test sample ranking method combining data distribution and graph analysis according to claim 1, characterized in that: Steps 2 and 3 extract the transition matrix of the sub-model output probability vector and the adjacency matrix of the model neuron activation map as sample features. This fully utilizes the white-box structure and parameter information of the model, as well as the dynamic features of the model decision-making process. This helps to more accurately identify test samples that cause model decision errors and locate defect sites in the model, thereby improving the efficiency of detecting model errors in the sorted test sample sequence. The sub-model is generated by fully connecting each hidden layer in the original DNN model to the output layer, removing the subsequent hidden layers, and retaining only the previous hidden layers. The construction method of the neuron activation graph is as follows: First, based on the DNN model structure, an undirected weighted graph is generated with neurons as nodes and model weights as edges. Then, the test samples are input into the DNN model, and only the activated part of the undirected weighted graph is retained. Finally, the weights and directions of the edges are modified according to the output of the neurons to obtain the directed weighted neuron activation graph.
4. The deep learning test sample ranking method combining data distribution and graph analysis according to claim 1, characterized in that: Step 5 uses two model output methods, geometric weighting and geometric weighting, to calculate the test sample score and guide the sample ranking. The calculation formula is shown in (1), where For the test sample score, and These represent the ranking scores given by the XGBoost model and the LightGBM model to the test samples, respectively. These are the hyperparameters that need to be tuned in the experiment.
Citation Information
Patent Citations
Acoustic model training method and device
CN104143327A
Integrated model-oriented robustness improvement defense method
CN113935496A