CertPri: Certifiable Prioritization for Deep Neural Networks via
  Movement Cost in Feature Space
Deep neural networks (DNNs) have demonstrated their outperformance in various
software systems, but also exhibit misbehavior and even result in irreversible
disasters. Therefore, it is crucial to identify the misbehavior of DNN-based
software and improve DNNs' quality. Test input prioritization is one of the
most appealing ways to guarantee DNNs' quality, which prioritizes test inputs
so that more bug-revealing inputs can be identified earlier with limited time
and manual labeling efforts. However, the existing prioritization methods are
still limited from three aspects: certifiability, effectiveness, and
generalizability. To overcome the challenges, we propose CertPri, a test input
prioritization technique designed based on a movement cost perspective of test
inputs in DNNs' feature space. CertPri differs from previous works in three key
aspects: (1) certifiable: it provides a formal robustness guarantee for the
movement cost; (2) effective: it leverages formally guaranteed movement costs
to identify malicious bug-revealing inputs; and (3) generic: it can be applied
to various tasks, data, models, and scenarios. Extensive evaluations across 2
tasks (i.e., classification and regression), 6 data forms, 4 model structures,
and 2 scenarios (i.e., white-box and black-box) demonstrate CertPri's superior
performance. For instance, it significantly improves 53.97% prioritization
effectiveness on average compared with baselines. Its robustness and
generalizability are 1.41~2.00 times and 1.33~3.39 times that of baselines on
average, respectively.
Haibin Zheng, Jinyin Chen, Haibo Jin
# CertPri: Certifiable Prioritization for Deep Neural Networks via Movement Cost in Feature Space

###### Abstract

Deep neural networks (DNNs) have demonstrated their outperformance in various software systems, but also exhibit misbehavior and even result in irreversible disasters. Therefore, it is crucial to identify the misbehavior of DNN-based software and improve DNNs' quality. Test input prioritization is one of the most appealing ways to guarantee DNNs' quality, which prioritizes test inputs so that more bug-revealing inputs can be identified earlier with limited time and manual labeling efforts. However, the existing prioritization methods are still limited from three aspects: certifiability, effectiveness, and generalizability. To overcome the challenges, we propose _CertPri_, a test input prioritization technique designed based on a movement cost perspective of test inputs in DNNs' feature space. CertPri differs from previous works in three key aspects: (1) _certifiable_ - it provides a formal robustness guarantee for the movement cost; (2) _effective_ - it leverages formally guaranteed movement costs to identify malicious bug-revealing inputs; and (3) _generic_ - it can be applied to various tasks, data, models, and scenarios. Extensive evaluations across 2 tasks (i.e., classification and regression), 6 data forms, 4 model structures, and 2 scenarios (i.e., white-box and black-box) demonstrate CertPri's superior performance. For instance, it significantly improves 53.97% prioritization effectiveness on average compared with baselines. Its robustness and generalizability are 1.41\(\sim\)2.00 times and 1.33\(\sim\)3.39 times that of baselines on average, respectively. The code of CertPri is open-sourced at [https://anonymous.4open.science/r/CertPri](https://anonymous.4open.science/r/CertPri).

 Deep neural network, test input prioritization, deep learning testing, movement cost, certifiable prioritization

## I Introduction

Deep neural networks (DNNs) [1] have performed impressive success in many fields, including computer vision [2, 3, 4], natural language processing [5, 6], and software engineering [7, 8], etc. However, like traditional software systems, DNNs are also vulnerable in terms of quality and reliability [9, 10, 11, 12]. Meanwhile, these vulnerabilities could lead to serious losses such as a crash caused by a Google self-driving car [13], and even irreversible disasters such as the deadly car crash caused by the autopilots of Tesla [14] and Uber [15]. Therefore, it is crucial to detect the misbehavior of DNN-based software and ensure DNNs' quality.

Much effort has been put into DNN-based software quality assurance [16, 17, 18, 19, 20, 12]. One of the most appealing methods is test input prioritization [21, 22], which prioritizes test inputs so that more bug-revealing inputs (e.g., misclassified inputs) can be identified earlier with limited time and manual labeling efforts. Moreover, these inputs facilitate the debugging of DNN-based software, which could improve DNNs' quality [23, 24] and reduce their retraining cost [25]. There are several prioritization methods, mainly including four aspects, i.e., coverage-based [26, 12, 20], surprise-based [27, 28, 22], confidence-based [23, 25, 29], and mutation-based [24] methods. The first two methods prioritize test inputs based on DNNs' neuron coverage and surprise-adequacy activation traces, respectively. Confidence-based methods identify bug-revealing inputs by measuring the classifier's output probabilities. Mutation-based methods design a series of mutation operations, and then analyze the mutated output probabilities based on supervised learning. These methods make great progress in identifying bug-revealing inputs earlier, but they still suffer from the following problems.

First, the existing methods are empirically lacking formal guarantees, which results in vulnerability against malicious attacks, i.e., prioritizing bug-revealing inputs at the back when attacked. More specifically, taking neuron activation suppression as an optimization objective, the adversary could craft imperceptible adversarial perturbations [30, 31]. These bug-revealing inputs with perturbations will be prioritized at the back due to low neuron coverage or inadequate activation traces, i.e., coverage-based and surprise-based methods lose their effectiveness. Similarly, confidence-based methods fail to work when increasing the highest probability value [32, 33] by adding well-designed perturbations to inputs. Mutation-based methods include input mutation and model mutation, both of which are similar to data augmentation [34, 35] and network modification [36, 37], respectively. Once the mutation operations are leaked, the adversary can bypass these operations by crafting malicious bug-revealing inputs. Then, mutation-based methods will be invalid. Therefore, a formal robustness guarantee for certifiable prioritization is required.

Second, almost all methods either suffer from prioritization effectiveness or efficiency issues. For instance, coverage-based methods have been demonstrated to be ineffective and time-costly [23]. Surprise-based methods improve test input prioritization by utilizing more advanced metrics (e.g., surprise-adequacy and activation frequency), but are computationally expensive due to more parameter tuning. Confidence
-based methods apply output probabilities to perform fast and lightweight prioritization, and their effectiveness is better than the previous two. However, once adversarial [32] or poisoned [38] inputs are injected into the test dataset, their effectiveness drops largely. Mutation-based test input prioritization, PRIMA [24], is the state-of-the-art (SOTA) method for DNNs, outperforming the confidence-based methods by an average of 10%, but with a time cost increase of more than 100 times. Moreover, PRIMA is a supervised prioritization method, i.e., its effectiveness is affected by training dataset size and category balance.

Third, most methods suffer from the generalizability issue, including the generalizability of tasks, data forms, model structures, and application scenarios. For instance, confidence-based methods rely on DNNs' output probabilities, and thus may not be directly generalized to a regression task. Meanwhile, their prioritization effectiveness for sequential data form (e.g., text data [5]) has been demonstrated to drop by an average of 30% in the existing study [24]. Mutation-based methods could be generalized to various data and tasks, but specialized domain knowledge is required to design diverse data-specific (e.g., structured data [39] and graph data [40]) mutation strategies. Moreover, it is unclear whether their model mutation strategies can still perform well on other model structures, such as graph convolution network (GCN) [40]. Except for confidence-based methods, the other three types are all designed for white-box testing and need to acquire DNNs' details. In black-box scenarios, these white-box methods will seriously degrade performance or even fail to work.

To overcome these challenges, our design goals are as follows: (1) we intend to take formal guarantee into account when designing a certifiable prioritization method; (2) we want the certifiability to serve prioritization effectiveness without degrading efficiency; (3) we plan to evaluate its generalizability.

One of the main contributions of DNNs is automatic feature extraction [1], which maps test inputs from the data space to the feature space. Based on the mapping ability, Zheng _et al_. [41] improved the robustness of DNNs by pushing the test input to the target position (i.e., class center) based on inverse perturbation. Further, we find that the inverse perturbation measures the movement cost of test inputs in feature space. Thus, we explore the variation in the movement cost of different test inputs and give an example as shown in Figure 1. We compute the movement cost (i.e., inverse perturbation based on infinite norm) of 5,000 test inputs from ImageNet [42] on a pre-trained VGG model [2]. We first divide test inputs into 10 groups according to the original prediction probability, and then calculate the movement cost of reaching a position with a higher probability. As shown in Figure 1, we find that there was a significant difference (p-value=2.38E-07 based on T-test) in the movement cost of correctly and incorrectly predicted test inputs, which can be considered for prioritization. However, the inverse perturbation [41] is obtained through iterative training, which is still empirical. To satisfy the certifiability requirement, we further derive a formal guarantee of the inverse perturbation with the Lipschitz continuity assumption [43].

According to the utility analysis and certifiability consideration, we design a certifiable prioritization technique, _CertPri_, which reduces the problem of measuring misbehavior probability to the problem of measuring the movement difficulty in feature space, i.e., the movement cost of the test inputs being close to or far from the class centers. Then, we compute the certifiable inverse perturbation based on the generalized extreme value theory (GEVT) [44]. Based on the formal robustness guarantee, CertPri is valid for identifying malicious bug-revealing inputs, as well as clean bug-revealing inputs, without degrading efficiency.

To compute the inverse perturbation, the model gradient is used [45]. Since DNNs are an end-to-end learning paradigm [46], the gradient can be directly computed when data and models are available in a white-box scenario. In a black-box scenario, the approximate gradient can be computed by gradient estimation [47]. Furthermore, to evaluate CertPri's generalizability, we conduct extensive experiments on various tasks, data forms, data types, model structures, training and prioritization scenarios.

The main contributions are as follows.

* Through inverse perturbation analysis and measurement, we first implement a formal robustness guarantee for the movement cost, which provides a new perspective for measuring DNNs' misbehavior probability.
* Based on the formal guarantee of movement costs, we propose an effective and efficient technique, CertPri, which leverages certifiability to facilitate the prioritization effectiveness.
* To evaluate CertPri's generalizability, we conduct extensive experiments on various tasks, data, models and scenarios, the results of which show the superiority of CertPri compared with previous works.
* We publish CertPri as a self-contained open-source toolkit online for facilitating DNNs' prioritization research.

## II Background

In this section, we first introduce the basic knowledge of DNNs, and then give the definitions of inverse perturbation.

### _Deep Neural Networks_

DNN consists of several layers, each of which contains a large number of neurons [1]. Generally, the basic tasks of DNNs include classification and regression. These tasks are accomplished by building models with various basic structures, such as fully connected network (FCN) [16], convolutional neural network (CNN) [2], long short-term memory (LSTM) [48], and GCN [40]. The classification and regression models are as follows.

The classification model predicts which class the test input belongs to. Suppose we have a \(K\)-class classifier \(f^{C}:\mathbb{R}^{d}\rightarrow\mathbb{R}^{K}\). Given a test input \(\mathbf{x}_{0}\in\mathbb{R}^{d}\), the classifier will output a
vector of \(K\) values normalized by softmax function [49], e.g., \(\{f_{i}^{C}(\mathbf{x}_{0})|_{1\leq i\leq K}\}\), each of which represents the probability that \(\mathbf{x}_{0}\) belongs to the \(i\)-th class, where \(\{d,K\}\in\mathbb{Z}^{+}\) and \(K\geq\)2. \(c(\mathbf{x}_{0})=\arg\max_{1\leq i\leq K}f_{i}^{C}(\mathbf{x}_{0})\) represents the predicted label of \(\mathbf{x}_{0}\) and \(f_{i}^{C}(\mathbf{x}_{0})\in(0,1)\).

The regression model describes a mapping between the test input and the output. Suppose we have a regression model \(f^{R}:\mathbb{R}^{d_{1}}\rightarrow\mathbb{R}^{d_{2}}\). Given a test input \(\mathbf{x}_{0}\in\mathbb{R}^{d_{1}}\), the regression model will output a vector with \(d_{2}\) elements activated by linear or ReLU functions [50], e.g., \(\{f_{i}^{R}(\mathbf{x}_{0})|_{1\leq i\leq d_{2}}\}\), each of which represents a fit to the ground-truth, where \(\{d_{1},d_{2}\}\in\mathbb{Z}^{+}\). \(r(\mathbf{x}_{0})=f^{R}(\mathbf{x}_{0})\) represents the fitted prediction output of \(\mathbf{x}_{0}\) and \(f_{i}^{R}(\mathbf{x}_{0})\in[\min_{r},\max_{r}]\).

### _Definitions of Inverse Perturbation_

We give definitions of inversely perturbed test input, minimum inverse perturbation, and lower bound.

**Definition 1** (inversely perturbed test input).: Given \(\mathbf{x}_{0}\), we say \(\mathbf{x}_{0}^{*}\) is an inversely perturbed test input of \(\mathbf{x}_{0}\) with inverse perturbation \(\mathbf{\mu}\) and \(l_{p}\)-norm \(\Delta_{p}\) if \(\mathbf{x}_{0}^{*}=\mathbf{x}_{0}+\mathbf{\mu}\) is moved to the target position and \(\Delta_{p}=||\mathbf{\mu}||_{p}\). An inversely perturbed test input for a classifier is \(\mathbf{x}_{0}^{*}\in\mathbb{R}^{d}\) that moves towards the class center of \(c(\mathbf{x}_{0})\), where the class center is defined as \(f_{center}^{C}(\mathbf{x}_{0})=\min\big{\{}f_{c}^{C}(\mathbf{x}_{0})\times[1+\log(1+f_ {c}^{C}(\mathbf{x}_{0}))],1\big{\}}\). For a regression model, \(\mathbf{x}_{0}^{*}\in\mathbb{R}^{d_{1}}\) moves from \(r(\mathbf{x}_{0})\) to regression center, which is defined as \(f_{i}^{R,\pm}(\mathbf{x}_{0})=\operatorname{clip}_{\min_{r}}^{\max_{r}}\big{(}f_{ i}^{R}(\mathbf{x}_{0})+|f_{i}^{R}(\mathbf{x}_{0})|\times\log\big{[}1+\tanh(f_{i}^{R }(\mathbf{x}_{0}))\big{]}\big{)}\).

**Definition 2** (minimum inverse perturbation \(\Delta_{p}^{\min}\) and its lower bound \(\gamma_{L}\)).: Given a test input \(\mathbf{x}_{0}\), the minimum \(l_{p}\) inverse perturbation of \(\mathbf{x}_{0}\), denoted as \(\Delta_{p}^{\min}\), is defined as the smallest \(\Delta_{p}\) over all inversely perturbed test inputs of \(\mathbf{x}_{0}\). Suppose \(\Delta_{p}^{\min}\) is the minimum inverse perturbation of \(\mathbf{x}_{0}\). A lower bound of \(\Delta_{p}^{\min}\), denoted by \(\gamma_{L}\) where \(\gamma_{L}\leq\Delta_{p}^{\min}\), is defined such that any inversely perturbed test inputs of \(\mathbf{x}_{0}\) with \(||\mathbf{\mu}||_{p}\leq\gamma_{L}\) will never reach the target position.

The lower bound of inverse perturbation measures the minimum movement cost for a test input to reach the target position (i.e., class center or regression center). \(\gamma_{L}\) guarantees that the inversely perturbed test input will never move to the target position for inverse perturbation with \(||\mathbf{\mu}||_{p}\leq\gamma_{L}\), certifying the movement cost of the test input. All the notations are summarized in Table I.

## III CertPri Methodology

In this section, we present a technical description of CertPri. First, we discuss the prioritization feasibility based on a movement cost view. Then, we introduce CertPri, which provides a formal robustness guarantee based on the Lipschitz continuity assumption [43] and estimates the movement cost based on GEVT [45]. Finally, we prioritize inputs via movement costs.

### _A Movement View in Feature Space_

A well-trained DNN implements feature extraction through multiple hidden layers, each of which filters redundant features and amplifies key features during forward propagation [51]. If we regard the feature mapping of hidden layers as data movement in feature space, almost all test inputs are pushed towards the target position in forward propagation, while bug-revealing inputs fail to reach the target position at the end of forward propagation.

First, we investigate the movement process of test inputs in forward propagation. Taking a classifier based on a FCN with three hidden layers on MNIST [52] dataset as an example, the t-SNE [53] based distribution of test inputs in feature space is visualized in Figure 2. During the forward propagation as shown in Figure 2 (a), we observe that most test inputs directional approach the correct class, which realizes the right prediction. However, several test inputs move without direction leading to the DNN's misbehavior (i.e., misclassification), which are the bug-revealing inputs that need to be identified. It is intuitively based on the feature purity theory of test inputs [23]. For a bug-revealing test input, it not only contains features of multiple classes, but the highest feature purity is close to the second highest one, and even the feature purity of each class is close. Thus, the movement of this test input in the forward propagation is directionless.

Then, we further analyze the movement cost of correctly and incorrectly predicted test inputs based on the inverse

Fig. 1: An example of movement cost for test inputs with different probability levels, where “*” and “*” represent correctly and incorrectly predicted test inputs, respectively. Subfigure (a) represents movement costs required for test inputs whose top-1 prediction probability belongs to (0, 0.1) to reach a position with a probability higher than 0.1, where the \(x\)-axis represents the original top-1 prediction probability and the \(y\)-axis represents the movement cost. We repeat 5 times and compute the average movement cost of each test input.
perturbation [41]. As shown in Figure 2 (b), the ground truth of \(\mathbf{x}_{0}\) is **II** but is misclassified as **III**. As \(\mathbf{x}_{0}\) proceeds along the gradient direction, its class center of **III** can be reached with low movement cost. However, correctly predicted test inputs require high movement cost to reach their class centers. It is consistent with the interpretation based on feature purity [23]. The incorrectly predicted test inputs improve the feature purity of the corresponding class after adding inverse perturbation, which turns random movement into directional movement in forward propagation. Therefore, only a low movement cost is required to reach the class center. The correctly predicted test inputs contain high feature purity, which keeps them stable in feature space. Thus, further movement requires a high cost. Note that the class center is given by **Definition 1**, which differs for each test input [41].

Based on the above analysis, we reduce the problem of measuring misbehavior probability of prioritization to the problem of measuring the movement cost in feature space. Thus, we prioritize test inputs by comparing their lower bounds of minimum movement cost to the target position. The test input never reaches the target position when the movement cost is less than the lower bound \(\gamma_{L}\). However, \(\gamma_{L}\) is not easy to find. Below we show how to derive a formal inverse perturbation guarantee of a test input with the Lipschitz continuity assumption [43].

### _Formal Guarantees for Movement Cost_

We first give the lemma about the Lipschitz continuity. According to the lemma, we then provide a formal guarantee for the lower bound of the inverse perturbation. Specifically, our analysis obtains a lower bound of \(l_{p}\)-norm minimum inverse perturbation \(\gamma_{L}=\min\frac{f^{C}_{center}(\mathbf{x}_{0})-f^{C}_{p}(\mathbf{x}_{0})}{L^{ \epsilon}_{q}}\) for a classifier and \(\gamma_{L}\!=\!\min\frac{\sum_{i}|f^{R}_{i,(\mathbf{x}_{0})}-f^{R}_{i}(\mathbf{x}_{0} )|}{d_{2}\times L^{\epsilon}_{q}}\) for a regression model.

**Lemma 1** (Norms and corresponding Lipschitz constants [43]).: _Let \(D\subset\mathbb{R}^{d}\) be a convex bounded closed set and let \(h(\mathbf{x}):S\rightarrow\mathbb{R}\) be a continuously differentiable function on an open set containing \(D\). For a Lipschitz function \(h(\mathbf{x})\) with Lipschitz constant \(L_{q}\), the inequality \(|h(\mathbf{a})-h(\mathbf{b})|\leq L_{q}||\mathbf{a}-b||_{p}\) holds for any \(\{\mathbf{a},\mathbf{b}\}\in D\), where \(L_{q}=\max\{||\nabla_{\mathbf{a}}h(\mathbf{x})||_{q}:\mathbf{x}\in D\}\), \(\nabla_{\mathbf{a}}h(\mathbf{x})=(\frac{\partial h}{\partial\mathbf{x}_{1}},...,\frac{ \partial h}{\partial\mathbf{x}_{d}})\) is the gradient of \(h(\mathbf{x})\), \(\frac{1}{p}+\frac{1}{q}=1\) and \(1\leq\{p,q\}\leq\infty\)._

**Theorem 1** (Formal guarantee on lower bound \(\gamma_{L}\) of inverse perturbation for classification model).: _Let \(\mathbf{x}_{0}\in\mathbb{R}^{d}\) and \(f^{C}:\mathbb{R}^{d}\rightarrow\mathbb{R}^{K}\) be a \(K\)-class classifier with continuously differentiable components. For all \(\mathbf{\mu}\in\mathbb{R}^{d}\) with \(||\mathbf{\mu}||_{p}\leq\min\frac{f^{C}_{center}(\mathbf{x}_{0})-f^{C}_{p}(\mathbf{x}_{0} )}{L^{\epsilon}_{q}}\), \(f^{C}_{c}(\mathbf{x}_{0}+\mathbf{\mu})=f^{C}_{center}(\mathbf{x}_{0})\) holds with \(\frac{1}{p}+\frac{1}{q}=1\), \(1\leq\{p,q\}\leq\infty\) and \(L^{\epsilon}_{q}\) is the Lipschitz constant for the function \(f^{C}_{center}(\mathbf{x})-f^{C}_{c}(\mathbf{x})\) in \(l_{p}\)-norm. In other word, \(\gamma_{L}=\min\frac{f^{C}_{center}(\mathbf{x}_{0})-f^{C}_{c}(\mathbf{x}_{0})}{L^{ \epsilon}_{q}}\) is a lower bound of minimum inverse perturbation for moving to the class center._

_Proof_. According to Lemma 1, the assumption that the function \(h(\mathbf{x}):=f^{C}_{center}(\mathbf{x})-f^{C}_{c}(\mathbf{x})\) is Lipschitz continuous with Lipschitz constant \(L^{\epsilon}_{q}\) gives:

\[|h(\mathbf{a})-h(\mathbf{b})|\leq L^{\epsilon}_{q}||\mathbf{a}-\mathbf{b}||_{p}. \tag{1}\]

Let \(\mathbf{a}=\mathbf{x}_{0}+\mathbf{\mu}\) and \(\mathbf{b}=\mathbf{x}_{0}\), we get:

\[|h(\mathbf{x}_{0}+\mathbf{\mu})-h(\mathbf{x}_{0})|\leq L^{\epsilon}_{q}||\mathbf{\mu}||_{p}, \tag{2}\]

which can be rearranged by removing the absolute symbol:

\[\begin{array}{l}-L^{\epsilon}_{q}||\mathbf{\mu}||_{p}\leq h(\mathbf{x}_{0}+\mathbf{\mu}) -h(\mathbf{x}_{0})\leq L^{\epsilon}_{q}||\mathbf{\mu}||_{p},\\ \Rightarrow h(\mathbf{x}_{0})-L^{\epsilon}_{q}||\mathbf{\mu}||_{p}\leq h(\mathbf{x}_{0}+\mathbf{ \mu})\leq h(\mathbf{x}_{0})+L^{\epsilon}_{q}||\mathbf{\mu}||_{p}.\end{array} \tag{3}\]

When \(h(\mathbf{x}_{0}+\mathbf{\mu})\!=\!0\), the inversely perturbed test input is moved to the class center. As represented by Equation (3), \(h(\mathbf{x}_{0})-L^{\epsilon}_{q}||\mathbf{\mu}||_{p}\) is the lower bound of \(h(\mathbf{x}_{0}+\mathbf{\mu})\). If \(h(\mathbf{x}_{0})-L^{\epsilon}_{q}||\mathbf{\mu}||_{p}\geq 0\) for sufficiently small inverse perturbation \(||\mathbf{\mu}||_{p}\), the inversely perturbed input cannot reach the class center, i.e.,

\[\begin{array}{l}h(\mathbf{x}_{0})-L^{\epsilon}_{q}||\mathbf{\mu}||_{p}\geq 0\ \Rightarrow||\mathbf{\mu}||_{p}\leq\frac{h(\mathbf{x}_{0})}{L^{\epsilon}_{q}}\\ \Rightarrow||\mathbf{\mu}||_{p}\leq\frac{f^{C}_{center}(\mathbf{x}_{0})-f^{C}_{c}( \mathbf{x}_{0})}{L^{\epsilon}_{q}}.\end{array} \tag{4}\]

To realize \(f^{C}_{c}(\mathbf{x}_{0}+\mathbf{\mu})=f^{C}_{center}(\mathbf{x}_{0})\) we take the minimum of the bound on \(||\mathbf{\mu}||_{p}\), i.e., the test input will never move to the class center when \(||\mathbf{\mu}||_{p}\leq\min\frac{f^{C}_{center}(\mathbf{x}_{0})-f^{C}_{c}(\mathbf{x}_{0} )}{L^{\epsilon}_{q}}\).

**Theorem 2** (Formal guarantee on lower bound \(\gamma_{L}\) of inverse perturbation for regression model).: _Let \(\mathbf{x}_{0}\in\mathbb{R}^{d_{1}}\) and \(f^{R}:\mathbb{R}^{d_{1}}\rightarrow\mathbb{R}^{d_{2}}\) be a regression model with continuously differentiable components. For all \(\mathbf{\mu}\in\mathbb{R}^{d_{1}}\) with \(||\mathbf{\mu}||_{p}\leq\min\frac{\sum_{i}|f^{R}_{i,+}(\mathbf{x}_{0})-f^{R}_{i}(\mathbf{x}_ {0})|}{L^{\epsilon}_{q}}\), \(\frac{1}{d_{2}}\sum|r(\mathbf{x}_{0}+\mathbf{\mu})-r(\mathbf{x}_{0})|\leq\delta\) holds with \(\frac{1}{p}+\frac{1}{q}=1\), \(1\leq\{p,q\}\leq\infty\) and \(L^{\epsilon}_{q}\) is the Lipschitz constant for the function \(\frac{\sum_{i}|f^{R}_{i,+}(\mathbf{x})-f^{R}_{i}(\mathbf{x}_{0})|}{d_{2}\times L^{ \epsilon}_{q}}\) in \(l_{p}\)-norm. In other word, \(\gamma_{L}=\min\frac{\sum_{i}|f^{R}_{i,+}(\mathbf{x}_{0})-f^{C}_{i}(\mathbf{x}_{0})|}{L^{ \epsilon}_{q}}\) is a lower bound of minimum inverse perturbation. The complete proof is deferred to [https://anonymous.4open.science/r/CertPri/SupplementaryMaterials.pdf](https://anonymous.4open.science/r/CertPri/SupplementaryMaterials.pdf).

Fig. 2: An example of t-SNE [53] based distribution visualization of test inputs in feature space. The classifier is a FCN with three hidden layers, the test inputs are handwritten digits of ”0”(I), “1”(II) and “2”(III) from MNIST dataset [52].
### _Movement Cost Estimation via GEVT_

The formal guarantees give that \(\gamma_{L}\) is related to \(h(\mathbf{x}_{0})\) and its Lipschitz constant \(L_{q}\), where \(L_{q}=\max\{||\nabla_{\mathbf{x}}h(\mathbf{x})||_{q}:\mathbf{x}\in B_{p}(\mathbf{x}_{0},\mathcal{ R})\}\), \(B_{p}(\mathbf{x}_{0},\mathcal{R}):=\{\mathbf{x}||_{\mathbf{x}=\mathbf{x}||_{p}\leq\mathcal{R}}\}\) is a hyperball with center \(\mathbf{x}_{0}\) and radius \(\mathcal{R}\). The value of \(h(\mathbf{x}_{0})\) is easily accessible at the model output. Thus, we show how to get \(\max||\nabla_{\mathbf{x}}h(\mathbf{x})||_{q}\).

For a random variable sequence \(\{\mathbf{x}_{0}^{(j)}\}\) sampled from \(B_{p}(\mathbf{x}_{0},\mathcal{R})\), its corresponding gradient norm can be regarded as a new random variable sequence \(\{||\nabla_{\mathbf{x}}h(\mathbf{x}_{0}^{(j)})||_{q}\}\) characterized by a cumulative distribution function (CDF) [45]. Therefore, we estimate \(\max||\nabla_{\mathbf{x}}h(\mathbf{x}_{0}^{(j)})||_{q}\) with a small number of samples based on GEVT, which ensures that the maximum value of a random variable sequence can only follow one of the three extreme value distributions [44]. The CDF of \(||\nabla_{\mathbf{x}}h(\mathbf{x}_{0}^{(j)})||_{q}\) is as follows:

\[G_{\xi}(\mathbf{z})=\exp\left(-(1+\xi\mathbf{z})^{-\frac{1}{\xi}}\right), \tag{5}\]

where \(1+\xi\mathbf{z}>0\), \(\mathbf{z}=\frac{||\nabla_{\mathbf{x}}h(\mathbf{x}_{0}^{(j)})||_{q}-u}{\sigma}\), \(\xi\in\mathbb{R}\) is a extreme value index, \(u\in\mathbb{R}\) and \(\sigma\in\mathbb{R}^{+}\) are the expectation and variance. The parameters \(u\), \(\sigma\) and \(\xi\) determine the location, scale and shape of \(G_{\xi}(\mathbf{z})\), respectively. \(G_{\xi}(\mathbf{z})\) belongs to either the Gumbel (\(\xi=0\)), Frechet (\(\xi>0\)) or Weibull (\(\xi<0\)) distributions.

We plot curves of probability density function (PDF) and its CDF for different extreme value distributions in Figure 3, where PDF (denoted as \(g_{\xi}(\mathbf{z})\)) is the differential of CDF. The Weibull distribution shows an interesting property in Figure 3, i.e., a finite right end-point (denoted as \(-\frac{1}{\xi}\)), which limits the upper bound of the distribution. Therefore, we adopt the Weibull to describe the gradient norm distribution, where the right end-point is the estimation of \(\max||\nabla_{\mathbf{x}}h(\mathbf{x})||_{q}\).

### _Prioritization through Movement Cost_

Based on the movement cost perspective in Section III-A, we can conclude that a test input with a small value of \(\gamma_{L}\) should be prioritized at the front. Therefore, we compute the \(\gamma_{L}\) value of each test input, and then prioritize these inputs according to their \(\gamma_{L}\) values from small to large. **Algorithm 1** shows the details of CertPri by taking the classification model as an example. We first establish the gradient norm distribution of a test input by randomly sampling in the hyper-ball (the loop from lines 4 to 9). Then, we estimate the location of the maximum gradient norm based on the Weibull distribution and compute the lower bound of the movement cost based on **Theorem 1** (lines 10 and 11). Finally, we repeat the above operations for each test input (the loop from lines 2 to 12) and prioritize them according to the ascending result of their \(\gamma_{L}\) values (line 13). Note that for algorithmic illustration, we only compute one \(g_{i,j}^{\max}\) (line 8) for each iteration. To implement the best efficiency of GPU, we usually evaluate these values in batches, and thus a batch of \(g_{i,j}^{\max}\) can be returned.

Furthermore, we can easily generalize CertPri to a regression model through replacing the \(h(\mathbf{x})\) function at line 1 with \(h(\mathbf{x}):=\frac{\sum_{i}|f_{i,j}^{R}(\mathbf{x})-f_{i}^{R}(\mathbf{x})|}{d_{2}}\) based on **Theorem 2**. Besides, we can extend CertPri to a black-box scenario based on the gradient estimation [47].

## IV Experimental Setting

In this section, we introduce the experimental setup, including the subjects we considered, the baselines we compared with, the measurements we used, and the implementation details we conducted.

### _Subjects_

We adopt 50 pairs of datasets and models as subjects, as shown in Table II. To sufficiently evaluate CertPri's effectiveness, efficiency, robustness, generalizability and guidance, we carefully consider the diversity of subjects from six dimensions. To our best knowledge, this is the most large-scale and diverse study in the field.

(1) **Various tasks of deep models.** We employ both classification models (ID: 1-32, 37-45, 47-49) and regression models (ID: 33-36, 46, 50). The number of classes ranges from 2 to 1,000 across all the classification tasks.

(2) **Various data forms of test inputs**. We consider six data forms of test inputs from 14 datasets, including image, text, speech, signal, graph, and structured data. Specifically, we collect _6 image datasets_, i.e., CIFAR10 [55] (a 10-class ubiquitous object dataset with 32\(\times\)32 pixels), ImageNet [42] (a 1,000-class object recognition benchmark with 224\(\times\)224 pixels), DrivingSA [56] (a steer angle regression dataset for autonomous driving from Udacity with 128\(\times\)128 pixels), Fashion-MNIST (FMNIST) [57] (a 10-class dataset of

Fig. 3: Curves of PDF and CDF for different distributions, where \(\xi=0\) for Gumbel, \(\xi=0.6\) for Fréchet and \(\xi=-0.6\) for Weibull, \(u=0\), \(\sigma=1\).
Zalando's article images with 28\(\times\)28 pixels), Ants_Bees (a binary insect dataset containing ants and bees for transfer learning with 224\(\times\)224 pixels), and Cats_Dogs (a binary pet dataset containing cats and dogs for transfer learning with 224\(\times\)224 pixels), _2 text datasets_, i.e., IMDB [58] (a binary movie review sentiment dataset encoded as a list of word indexes) and Reuters (a 46-class newswire dataset), _one speech dataset_, i.e., VCTK10 (a 10-class dataset of ten English speakers with various accents selected from VCTK Corpus with 601\(\times\)64 phonemes), _one signal dataset_, i.e., RML8PSK [59] (a signal regression dataset modulated by 8PSK from RadioML 2016.10a with 127\(\times\)2 points as input and 2 points as output), _one graph dataset_, i.e., Cora [60] (a 7-class citation network of scientific publications with 5,429 links), and _3 structured datasets_, i.e., Adult [61] (a binary income dataset with 13-dimensional attributes), COMPAS (a binary crime prediction dataset with 400-dimensional attributes), and Boston (a housing price regression dataset with 13-dimensional input and 1-dimensional output).

(3) **Various data types of test inputs**. We mainly consider three data types, including original test inputs, adversarial test inputs, and adaptive attacked test inputs. For _adversarial test inputs_, we perform three widely-used adversarial attacks (i.e., basic iterative method (BIM) [62], Carlini & Wagner (C&W) [63] and FineFool [64]) to generate the same number of adversarial examples as the corresponding original test inputs for CIFAR10 and ImageNet, respectively. Then, following previous works [23, 24], we construct an adversarial test input set for each of the two datasets under each adversarial attack through randomly selecting half of the original test inputs and half of the adversarial examples, represented as "+BIM", "+C&W", "+FineFool". For _adaptive attacked test inputs_, we follow the strategy introduced in Section I to produce them. Regarding the surprise-based method [28], we consider two objectives, flipping the labels of test inputs, and reducing their surprise (i.e., the activation difference between test inputs and the training inputs), which can be conducted by MAG-GAN [32]. Regarding confidence-based methods [23, 25], we first flip the labels of test inputs based on BIM [62], and then increase their highest probability value (up to 0.99 for CIFAR10 and 0.90 for ImageNet) by continuously adding perturbations. Regarding the mutation-based method [24], we first break its ranking model by adding noise to the extracted features, and then add perturbations to the test inputs based on back propagation [54] to generate noisy features. Finally, we construct an adaptive attacked test input set for each of the two datasets under each adaptive attack through randomly selecting half of the original test inputs and half of the adaptive attacked examples, represented as "+AdapS", "+AdapC", "+AdapM". When crafting adversarial or adaptive attacked test inputs, we assume that the adversary knows the prioritization details.

Additionally, regarding VGG19-AD model, we implement three test input types respectively, i.e., the original one, the patched test inputs (randomly blocking 10% of pixels for each test input), and the saturation-modified test inputs (modifying the intensities of saturation channel [65] for each test input).

(4) **Various structures of deep models**. We employ CNN (ID: 1-41, 43), LSTM (ID: 42, 44-46), GCN (ID: 47) and FCN (ID: 48-50). The number of layers ranges from 3 to 101 across all models.

(5) **Various training scenarios**. We set up three training scenarios, including normal training, poisoning and transfer learning. For the _poisoning scenario_, we first craft a poisoned training set on FMNIST dataset, denoted as "FMNIST_P", where the poisoning method is DeepPoison [66], the source label and poisoned label are "Pullover" and "Coat", respectively. For the _transfer learning scenario_, we deploy the source domain as ImageNet with 1,000-class and the target domain as insect images or pet images with 2-class.

(6) **Various prioritization scenarios**. We set up two prioritization scenarios, including white-box and black-box. All details of the model and test inputs are available and used for prioritization in the _white-box scenario_ (ID: 1, 3-9, 11-17, 19
25, 27-33, 35-50), while only model outputs and test inputs are available in the _black-box scenario_ (ID: 2, 10, 18, 26, 34).

### _Baselines_

We consider five baselines, i.e., likelihood-based surprise adequacy (LSA) [28], distance-based surprise adequacy (DSA) [28], multiple-boundary clustering and prioritization (MCP) [25], DeepGini [23] and PRIMA [24]. LSA and DSA are surprise-based methods. MCP and DeepGini are efficient confidence-based methods for lightweight prioritization. PRIMA is an effective mutation-based method with the SOTA performance. The application scope of each method is shown in Table III, where "\(\mathcal{X}\)" means PRIMA can only perform input mutation in the black-box scenario. Note that coverage-based methods have been shown to be significantly less effective [23] and thus are omitted. All baselines are configured according to the best performance setting reported in the respective papers.

### _Measurements_

We investigate CertPri's prioritization performance from five aspects, including prioritization _effectiveness_, _efficiency_, _robustness_, _generalizability_ and _guidance_.

(1) We evaluate the effectiveness of CertPri through the ratio of the area under curve (RAUC), which transforms the prioritization result to a curve [24], defined as follows for classification tasks:

\[\mathrm{RAUC}\!=\!\frac{\sum_{i=1}^{N}n_{i}}{N\!\times\!N^{\prime}\!+\!\frac{N ^{\prime}\!-\!N^{\prime 2}}{2}},\ \mathrm{where}\ n_{i}\!=\!\left\{\!\!\begin{array}{l}n_{i \!+\!1}\!+\!1,\ c(\mathbf{x}_{i})\ \mathrm{is\ correct}\\ n_{i\!-\!1},\ \mathrm{otherwise}\end{array}\right., \tag{6}\]

where \(N\) and \(N^{\prime}\) are the number of prioritized test inputs and bug-revealing inputs, \(i\geq 1\) and \(n_{0}=0\). In other words, the numerator and denominator represent the area under curve of the prioritization method and the ideal prioritization, respectively.

For regression tasks, RAUC is calculated based on the mean-square error (MSE) of prediction, as follows:

\[\mathrm{RAUC}=\frac{\sum_{i=1}^{N}m_{i}}{\sum_{j=1}^{N}M_{j}}\ \mathrm{where}\left\{ \begin{array}{l}m_{i}=m_{i\!+\!1}+\mathrm{MSE}\left(f^{R}(\mathbf{x}_{i}) \right)\\ M_{j}\!=M_{j\!+\!1}+\mathrm{MSE}\left(f^{R}(\mathbf{x}_{j})\right)\end{array} \right., \tag{7}\]

where \(m_{i}\) and \(M_{j}\) represent the accumulated MSE between the predicted results and the ground-truth of the prioritization method and the ideal prioritization, respectively. \(i,j\geq 1\), \(m_{0}=M_{0}=0\). Moreover, we follow the setup of Wang _et al._[24], using RAUC-100, RAUC-200, RAUC-300, RAUC-500 and RAUC-all as fine-grained metrics, i.e. \(N\)=100, 200, 300, 500 and all. Larger RAUC is better.

(2) We evaluate the prioritization efficiency of CertPri through prioritization speed, i.e., the time cost of prioritize 1,000 test inputs (#seconds/1,000 Inputs). Smaller is better.

(3) We evaluate the prioritization robustness of CertPri through RAUC stability, denoted as RobR. Larger RobR is better, as follows:

\[\mathrm{RobR}=\frac{\mathrm{RAUC}\!-\!\mathrm{all\ of\ adaptive\ attacked\ test\ inputs}}{\mathrm{RAUC}\!-\!\mathrm{all\ of\ original\ test\ inputs}}\times 100\%. \tag{8}\]

(4) We evaluate the prioritization generalizability of CertPri based on reward value, denoted as GenRew, as follows:

\[\mathrm{GenRew}=\frac{1}{N_{rep}\times N_{sub}}\sum_{i=1}^{N_{rep}}\sum_{j=1}^ {N_{sub}}\frac{n_{pm}-k_{i,j}+1}{n_{pm}}, \tag{9}\]

where \(N_{sub}\) represents the number of selected subjects, \(N_{rep}\!=\!5\) and \(n_{pm}\!=\!6\) are the number of repetitions and prioritization methods in our experiments, respectively. \(k_{i,j}\!\in\!\{1,2,...,n_{pm}\}\) represents that the method ranks in the \(k\)-th position in descending order of RAUC-all for the \(j\)-th subject at the \(i\)-th experimental repetition. GenRew \(\in[\frac{1}{n_{pm}},1]\). Lager GenRew is better.

(5) We evaluate the prioritization guidance from two aspects: performance and robustness improvements for DNNs. The former subtracts the accuracy of original model from that of retrained model, while the latter subtracts the attack success rate [32] of retrained model from that of original model.

### _Implementation Details_

To fairly study the performance of the baselines and CertPri, our experiments have the following settings. **(1) Hyperparameter settings** based on the double-minimum strategy: we conduct a preliminary study based on a small dataset, and find that \(N_{b}\)3, \(N_{rsb}\)5 and \(0.02\max(\mathbf{x})_{\mathrm{i}}\mathcal{R}_{\mathrm{i}}0.05\max(\mathbf{x})\) for Algorithm 1 are effective in general. To guarantee CertPri's effectiveness, we follow the double-minimum strategy, i.e., \(N_{b}\)=6, \(N_{rsb}\)=10, \(\mathcal{R}\)=0.04\(\max(\mathbf{x})\), \(p\)=2 for Algorithm 1.

**(2) Model training**: we download and use pretrained models on ImageNet. For other datasets, we train appropriate models as follows. The learning rate ranges from 1E-04 to 1E-02, the optimizer is Adam, training:validation:test = 7:1:2, and an early stop strategy is used to avoid overfitting. **(3) Preprocessing**: we fill in missing data points based on the mean value. There is no specific mutation strategy provided in PRIMA [24] for speech, signal, graph data forms and GCN model, thus we derive it from the existing mutation operations. **(4) Data recording**: we repeat the experiment 5 times and record about 9,000 raw data.

We conduct all the experiments on a server with one Intel i7-7700K CPU running at 4.20 GHz, 64 GB DDR4 memory, 4 TB HDD and one TITAN Xp 12 GB GPU card.

## V Experimental Results and Analysis

We evaluate CertPri through answering the following research questions (RQ).

**RQ1. Effectiveness**: How _effective_ is CertPri?

**RQ2. Efficiency**: How _efficient_ is CertPri.?
**RQ3. Robustness**: How _robust_ is CertPri?
**RQ4. Generalizability**: How _generic_ is CertPri?
**RQ5. Guidance**: Can CertPri _guide_ the retraining of DNNs?

### _Effectiveness (RQ1)_

How _effective_ is CertPri in prioritizing test inputs?

When reporting the results, we focus on the effectiveness of the following aspects: overall, data forms, data types, training scenarios, and prioritization scenarios. The evaluation results are shown in Tables IV, V, VI, VII, VIII and IX.
forms (i.e., image, text, etc). For instance, in Table VI, almost all RAUC values of CertPri are the highest, except RAUC-all on speech and graph data forms. We investigate their model feature space and find that their decision boundaries are smoother than others, which causes gradient vanishing. Therefore, we extend the sampling radius \(\mathcal{R}=0.05\max(\mathbf{x})\), which facilitates maximum gradient norm estimation based on GEVT. After radius extension, CertPri realizes the highest average RAUC-all, improving to 0.9127 and 0.8817 for speech and graph data forms, respectively. Additionally, the average RAUC of CertPri is 1.13\(\sim\)1.30 times that of baselines for unstructured data forms, but only 1.07 times for structured data. We speculate that the gradient vanishes during back propagation due to the sparse coding of structured data. Gradient vanishing is beyond the scope of this paper, but it can be improved by batch normalization [67] and non-saturating activation function [50].

**Effectiveness on various data types of test inputs**. CertPri largely outperforms all baselines against adaptive attacks in terms of all average RAUC values, while approaching the SOTA baseline (i.e., PRIMA) against adversarial attacks. For instance, in Table VII, the average RAUC values of CertPri against adaptive attacks range from 0.7006 to 0.8827 with average improvements of 64.73%\(\sim\)114.85% compared with DeepGini and 49.55%\(\sim\)64.11% compared with PRIMA, respectively. This is mainly because we provide a formal guarantee of movement costs in feature space, which cannot be an objective of adaptive attacks. Besides, the average RAUC-100 and RAUC-300 gaps between PRIMA and CertPri are both less than 0.02, which is acceptable and does not hinder its practical application in various data types.

**Effectiveness on various training scenarios**. CertPri outperforms DeepGini and shows competitive performance with PRIMA in both training scenarios. For instance, in Table VIII, the average RAUC values of CertPri range from 0.9769 to 0.9908 with average improvements of 81.20%\(\sim\)116.56% compared with DeepGini in the poisoning scenario, and range from 0.8274 to 0.9532 with average improvements of 11.10%\(\sim\)17.92% compared with DeepGini in transfer learning. Besides, the average RAUC-100 and RAUC-500 gaps between PRIMA and CertPri are both less than 0.02. We speculate that the purity assumption of DeepGini is not tenable in the two training scenarios [24], whereas CertPri and PRIMA facilitate their prioritization based on the movement cost and mutation perspectives, respectively.

**Effectiveness on various prioritization scenarios**. CertPri largely outperforms all baselines in terms of all RAUC values in both prioritization scenarios, which is beneficial to identify bug-revealing inputs in software engineering testing with privacy requirements. For instance, in Table IX, the average RAUC values of CertPri range from 0.7909 to 0.9039 with average improvements of 13.66%\(\sim\)44.65% compared with baselines in the white-box scenario, and range from 0.7227 to 0.8688 with average improvements of 8.94%\(\sim\)92.12% compared with baselines in the black-box scenario. The outstanding performance of CertPri is mainly because it leverages the Weibull distribution to determine the exact maximum gradient norm in the white-box scenario, and adopts gradient estimation to satisfy the black-box scenario.

_Answer to RQ1_: CertPri outperforms baselines in two aspects in terms of effectiveness: (1) _overall_-it significantly improves 81.84%, 47.48% and 18.65% RAUC values on average compared with surprise-based, confidence-based and mutation-based baselines, respectively; (2) _specific_-it improves 20.66%, 43.39%, 28.96% and 38.88% RAUC values on average compared with baselines (i.e., DeepGini and PRIMA) for various data forms, data types, training scenarios and prioritization scenarios, respectively.

### _Efficiency (RQ2)_

How _efficient_ is CertPri in prioritizing test inputs?

When answering this question, we refer to the prioritization time costs in the white-box scenarios with image data form (i.e., ID: 1-36). The evaluation results are shown in Table X, where the time cost of PRIMA includes input mutation, model mutation and ranking model training. Here we have the following observation.

**Prioritization efficiency**. CertPri prioritizes test inputs more efficiently than mutation-based methods and is competitive with confidence-based methods, which meets the rapidity requirements of software engineering testing. For instance, in Table X, the efficiency of CertPri is 41.17 times and 52.86 times that of DSA and PRIMA, respectively. This is mainly because CertPri only needs to perform gradient computation based on back propagation and extreme value estimation, both of which are lightweight operations. Besides, in Table X, the time cost of CertPri is 1.25 times and 2.94 times more
than that of MCP and DeepGini on average, respectively. The reason is that CertPri involves iterative operations in the extreme value estimation, which increases time costs. Note that CertPri adopts a double-minimum strategy to ensure its effectiveness, which leaves room for efficiency improvements. We can slightly reduce the \(N_{b}\), \(N_{rsb}\), \(\mathcal{R}\) values in **Algorithm 1** to further improve its efficiency without loss of effectiveness.

### _Robustness (RQ3)_

How _robust_ is CertPri against adaptive attacks based on its certifiability?

When reporting the results, we focus on the following aspects: the robustness against adaptive attacks and the utility of robustness. The evaluation results are shown in Table XI and Figure 4.

Implementation details for robustness evaluation. (1) To measure CertPri's robustness, we refer to the variation of RAUC values between original test inputs (ID: 1, 9, 17, 25) and adaptive attacked test inputs (ID: 6-8, 14-16, 22-24, 30-32), i.e., RobR, as shown in Table XI. (2) To demonstrate the robustness utility, taking adaptive attacks on ImageNet dataset as an example (ID: 22-24), we combine CertPri with each baseline to show the promotion effect of CertPri on baselines, as shown in Figure 4, where \(x\)-axis represents the percentage of CertPri components added to baselines.

**Prioritization robustness**. In all cases, CertPri always performs the most robust prioritization results against various adaptive attacks, which facilitates stable identification of bug-revealing inputs. For instance, in Table XI, the average RobR values of CertPri against adaptive attacks range from 99.93% to 103.60%, which is 1.50\(\sim\)1.71 times that of baselines. The outstanding performance of CertPri is mainly because it simplifies the prioritization task into a lower bound measure of the movement cost, which has been formally guaranteed in Section III-B.

**Utility of robustness**. CertPri is not only immune to various adaptive attacks, but also facilitates the robustness of baselines through weighted combinations. For instance, in Figure 4, all curves show an upward trend after combining with CertPri and are always higher than their initial value without CertPri. Furthermore, we speculate that for an empirical prioritization method that outperforms CertPri in general, it can be combined with CertPri to improve robustness against adaptive attacks.

_Answer to RQ3_: CertPri largely outperforms baselines in terms of robust prioritization with average robustness improvements of 41.37%\(\sim\)98.91%. Besides, its robustness can be leveraged to facilitate other methods.

### _Generalizability (RQ4)_

How _generic_ is CertPri in prioritizing test inputs?

When reporting the generalizability, we focus on the ranking of RAUC values for different methods in each subject. The evaluation results are illustrated as radar charts in Figure 5.

Implementation details for generalizability evaluation. (1) Calculate the GenRew value of each dimension separately. Take the task dimension as an example, which includes classification and regression. First, we select all subjects belonging to the classification task and calculate GenRew according to Equation (9), denoted as GR\({}_{c}\). Then, we select all subjects belonging to the regression task and compute GenRew, denoted as GR\({}_{r}\). Finally, we compute the average of GR\({}_{c}\) and GR\({}_{r}\) as the task-dimensional GenRew. (2) Repeat the above operations for the remaining 5 dimensions (i.e., data form/type, structure, training/prioritization scenarios).

**Prioritization generalizability**. CertPri always outperforms all baselines against various dimensions in terms of all average GenRew values. For instance, in Figure 5, the area of CertPri covers all baselines. More specifically, the average GenRew values of CertPri range from 0.9040 to 0.9813 with average improvements of 32.81%\(\sim\)238.54% compared with baselines. This is mainly because CertPri's calculation only involves gradient derivation based on back propagation, which is easy to implement for any DNN. Thus, CertPri can be generalized to various dimensions.

Fig. 4: The promotion results of CertPri for baselines through combining it with each baseline.
_Answer to RQ4_: CertPri is more generic than baselines in all six dimensions with average generalizability improvements of 32.81%\(\sim\)238.54%.

### _Guidance (RQ5)_

Can CertPri _guide_ the retraining of DNNs to improve their performance and robustness?

When reporting the guidance, we focus on two aspects: accuracy improvement and robustness improvement for DNNs. The evaluation results are illustrated as boxplots in Figure 6.

Implementation details for guidance evaluation. Take the classification on CIFAR10 as an example. (1) In terms of performance (ID: 1, 9), we sample original data prioritized at the front 1% and 5% in the training set. We set epoch=5 for retraining due to the small number of data. We compare the test accuracy. (2) In terms of robustness (ID: 3-5, 11-13), we sample adversarial data prioritized at the front 1% and 5% in the adversarial set. We mix the sampled data with the original training set, and set epoch=2 for retraining due to a large number of data. Repeat the above operations 5 times.

**Accuracy improvement for DNNs**. The original test inputs prioritized at the front facilitate model accuracy through retraining, where CertPri demonstrates SOTA accuracy improvement. For instance, in Figure 6 (a), the box position of CertPri is significantly higher than that of baselines. More specifically, the average accuracy improvements of CertPri range from 4.50% to 8.36%, which is 1.65\(\sim\)3.47 times that of baselines. It demonstrates CertPri's outstanding guidance for the accuracy improvement of DNNs.

**Robustness improvement for DNNs**. The adversarial test inputs prioritized at the front facilitate model robustness through retraining, where CertPri outperforms surprise-based methods and shows competitive performance with confidence-based and mutation-based methods. For instance, in Figure 6 (b), the box position of CertPri is significantly higher than that of LSA and DSA, while close to that of MCP, DeepGini and PRIMA. It demonstrates CertPri's guidance for the robustness improvement of DNNs.

_Answer to RQ5_: CertPri guides DNNs' retraining with only first 1% or 5% prioritized test inputs, which improves accuracy by 6.15% and robustness by 31.07% on average.

## VI Threats to Validity

Three aspects may become the threats to validity of CertPri.

The _internal_ threat to validity mainly lies in the center position determination. There are differences in movement costs to reach different centers, especially for non-uniformly distributed data in feature space. To reduce the internal threat, we customize the center position for each test input in **Definition 1**, i.e., relative center. Besides, we collect a large number of subjects with great diversity, and perform extensive experiments to verify CertPri's utility.

The _external_ threats to validity mainly lie in the non-differentiable component and gradient vanishing. To reduce these threats, we further extend **Theorems 1** and **2** to a special case of non-differentiable functions, i.e., a model with ReLU activation, as shown in [https://anonymous.4open](https://anonymous.4open). science/r/CertPri/SupplementaryMaterials.pdf. Then, we leverage batch normalization and non-saturating activation to reduce the probability of gradient vanishing and enlarge the sampling radius of the hyper-ball.

The _construct_ threats to validity mainly lie in the hyperparameters in CertPri, including \(N_{b}\), \(N_{rsb}\) and \(\mathcal{R}\) values in **Algorithms 1**. Larger hyperparameter values produce better effectiveness, but reduce efficiency. To reduce the threat from the hyperparameters, we conduct a double-minimum strategy. Besides, the norm value \(p\)=2 and the extreme value distribution type is Weibull in our experiments. In future work, we can explore prioritization results for various norm types and extreme value distributions.

## VII Related Works

To solve the labeling-cost problem in DNN testing, several works on test input prioritization are proposed [22, 23, 24, 25, 24, 26, 27, 28, 69, 29].

From the perspective of statistical analysis, there are coverage-based [20, 26, 70, 12], surprise-based [22, 27, 68, 28], and confidence-based methods [23, 25, 29]. Feng _et al._[23] comprehensively analyzed coverage-based methods and concluded that their effectiveness and efficiency are unsatisfactory for prioritization tasks. To improve effectiveness, Byun _et al._[22] prioritized test inputs based on surprise adequacy metrics. Zhang _et al._[27] observed the activation

Fig. 5: Generalizability comparison for six dimensions across all subjects, measured by GenRev.

Fig. 6: Guidance comparison of accuracy and robustness improvements for different methods under the first 1% and 5% prioritized data sampling (from left to right).
pattern of neurons, and produced prioritization results according to the activation patterns between the training set and test inputs. Ma _et al._[68] considered the interaction between test inputs and model uncertainty, and determined bug-revealing inputs with higher uncertainty. These surprise-based methods improve performance, but their prioritization results are related to the training set quality. Furthermore, Zhang _et al._[29] prioritized test inputs based on noise sensitivity analysis, independent of the training set. Shen _et al._[25] proposed MCP, in which clusters test inputs into the boundary areas and specify the priority to select them evenly. Feng _et al._[23] proposed DeepGini, which prioritizes test input by measuring set impurity. These confidence-based methods are effective and efficient, but only for classification tasks.

Drawing lessons from the mutation view in software engineering [71, 72], Wang _et al._[24] proposed PRIMA, which gives priority to test inputs that generate different predictions through diversity mutations (i.e., input-level and model-level). PRIMA demonstrates SOTA performance, but cannot be applied to black-box scenarios.

Different from them, CertPri prioritizes test inputs based on movement view in feature space. Besides, it takes robustness certification into account. Robustness certification [45, 48, 73] provides formal guarantees for DNNs against norm bounded attacks, which also facilitates CertPri against adaptive attacks. To the best of our knowledge, CertPri is the first to consider the prioritization robustness and introduce formal guarantees to provide certifiability.

## VIII Conclusions

We propose a certifiable prioritization method for bug-revealing test input identification earlier, CertPri, to efficiently solve the labeling-cost problem in DNN testing and build trustworthy deep learning systems. CertPri provides a new perspective on prioritization, which reduces the problem of measuring misbehavior probability to the problem of measuring the movement difficulty in feature space. Based on this view, we give formal guarantees about lower bounds \(\gamma_{L}\) on movement cost, and compute \(\gamma_{L}\) value based on GEVT. The priority of each test input is determined in ascending order of \(\gamma_{L}\) value. Furthermore, we generalize CertPri in black-box scenarios by gradient estimation. CertPri is compared with baseline on various tasks, data forms, data types, model structures, training and prioritization scenarios. The results show that CertPri outperforms baselines in terms of effectiveness, efficiency, robustness, generalizability and guidance.
