Generalized Uncertainty of Deep Neural Networks: Taxonomy and
  Applications
Deep neural networks have seen enormous success in various real-world
applications. Beyond their predictions as point estimates, increasing attention
has been focused on quantifying the uncertainty of their predictions. In this
review, we show that the uncertainty of deep neural networks is not only
important in a sense of interpretability and transparency, but also crucial in
further advancing their performance, particularly in learning systems seeking
robustness and efficiency. We will generalize the definition of the uncertainty
of deep neural networks to any number or vector that is associated with an
input or an input-label pair, and catalog existing methods on ``mining'' such
uncertainty from a deep model. We will include those methods from the classic
field of uncertainty quantification as well as those methods that are specific
to deep neural networks. We then show a wide spectrum of applications of such
generalized uncertainty in realistic learning tasks including robust learning
such as noisy learning, adversarially robust learning; data-efficient learning
such as semi-supervised and weakly-supervised learning; and model-efficient
learning such as model compression and knowledge distillation.
Chengyu Dong
# Generalized Uncertainty of Deep Neural Networks: Taxonomy and Applications

###### Abstract

Deep neural networks have seen enormous success in various real-world applications. Beyond their predictions as point estimates, increasing attention has been focused on quantifying the uncertainty of their predictions. In this review, we show that the uncertainty of deep neural networks is not only important in a sense of interpretability and transparency, but also crucial in further advancing their performance, particularly in learning systems seeking robustness and efficiency. We will generalize the definition of the uncertainty of deep neural networks to any number or vector that is associated with an input or an input-label pair, and catalog existing methods on "mining" such uncertainty from a deep model. We will include those methods from the classic field of uncertainty quantification as well as those methods that are specific to deep neural networks. We then show a wide spectrum of applications of such generalized uncertainty in realistic learning tasks including robust learning such as noisy learning, adversarially robust learning; data-efficient learning such as semi-supervised and weakly-supervised learning; and model-efficient learning such as model compression and knowledge distillation.

## 1 Introduction

Despite the vast success of deep neural networks, their decision process is hard to interpret and is known as a black box. In real-world applications, it is necessary that a decision system is not only accurate but also trustworthy, in the sense that it must know when it is likely to make errors (Guo et al., 2017). The interpretability and transparency of the decision process of deep neural networks have thus gained increasing attention, around which the pivot is often a reliable uncertainty measure that users can judge and manage the decisions. A variety of uncertainty measures and strategies to improve them have been developed so far.

In this review, we show that the uncertainty estimates of deep neural networks are important not only in improving their trustworthiness, but also in further advancing their performance, particularly in terms of robustness and efficiency. We will first review the possible uncertainty estimates we can leverage for deep neural networks. These include the classic definition of uncertainty, for example, the maximum probability or entropy of the predictive distribution, as well as strategies to improve it such as a diverse form of ensemble techniques. These ensemble techniques are mostly unique to deep neural networks, which either utilize the specific design in the network architecture such as MC-dropout (Gal and Ghahramani, 2016), or utilize the distinct optimization process of deep neural networks such as Snapshot ensemble (Huang et al., 2017).

We will further investigate the uncertainty estimates that are defined beyond the predictive distribution. For this, we generalize the definition of uncertainty from an estimate associated with a model prediction to any number or vector associated with a data example, where the label can either be provided or missing. We see that under such a definition, multiple intriguing properties of deep neural networks can be leveraged to define an uncertainty estimate. These include measures based
on inference dynamics of deep neural networks such as prediction depth (Baldock et al., 2021), and measures based on training dynamics of deep neural networks such as learning order (Arpit et al., 2017; Hacohen et al., 2020).

Finally, we discuss the potential applications of these uncertainty estimates in various learning problems, particularly when robustness and efficiency are of major interest. We show that in realistic datasets where the labels are expensive to obtain or the label noise is pervasive, reliable uncertainty estimates can be utilized to improve the performance greatly. We also show that uncertainty estimates can be utilized to enhance the performance of deep neural networks under adversarial attacks (Goodfellow et al., 2015). We then move to learning problems where the computation cost is prohibitive. We show that reliable uncertainty estimates can improve both the training and inference efficiency of deep neural networks, when utilized in advanced efficient learning techniques such as knowledge distillation (Hinton et al., 2015) and adaptive inference time (Graves, 2016).

This review will be structured as follows. In Section 2, we will introduce the necessary background such as the design, training and inference of deep neural networks, as well as the generalized definition of uncertainty. In Section 3, we will review various existing uncertainty estimates under such a definition, along with their problems and the strategies to improve them. In Section 4, we demonstrate how we can use the uncertainty estimates of deep neural networks to advance their performance in robust and efficient learning. Finally, Section 5 concludes our review and illuminates the potential opportunities in this direction.

## 2 Preliminaries

### Deep neural networks

We consider a supervised learning setting where a deep neural network \(f_{\theta}\) is defined as a function mapping from input domain \(\mathcal{X}\) to output domain \(\mathcal{Y}\), namely \(f_{\theta}:\mathcal{X}\rightarrow\mathcal{Y}\). A deep neural network usually consists of multiple feed-forward layers, where each layer \(l\) is parameterized by a set of weights \(\theta_{l}\). We denote the function mapping of the deep neural network up to layer \(L\) as \(f_{\theta_{1:L}}\). With a slight abuse of notation, we denote the function mapping of all layers, or the entire deep neural network as \(f_{\theta}\). Note that it is not necessarily the case that \(f_{\theta_{1:L}}(x)\in\mathcal{Y}\), namely the output of an intermediate layer can have higher or lower dimensionality than the output domain. During inference, given any unseen example input-label pair \((x,y)\), where \(x\in\mathcal{X}\) and \(y\in\mathcal{Y}\), a deep neural network accepts \(x\) and produces a prediction \(f_{\theta}(x)\), where we expect \(f_{\theta}(x)=y\).

\[y=f_{\theta}(x)\]

Training a deep neural network usually requires a training sample, namely a set of input-label pairs \(\mathcal{D}=\{(x_{i},y_{i})\}_{i=1}^{N}\). The most commonly used method to train a deep neural network is empirical risk minimization. We first define a distance function in the output domain \(l:\mathcal{Y}\times\mathcal{Y}\rightarrow\mathbb{R}\), which we typically refer as the loss function. It is desired that such a distance function suffices \(l(y_{1},y_{2})\geq 0\) for any \(y_{1},y_{2}\in\mathcal{Y}\) and \(l(y,y)=0\) for any \(y\in\mathcal{Y}\). Empirical risk minimization can be defined as

\[\theta^{*}=\arg\min_{\theta}\sum_{(x,y)\in\mathcal{D}}l(f_{\theta}(x),y), \tag{1}\]

namely we seek an optimal set of model weights that minimize the distance between the network outputs and the labels for all training examples.

To solve such a minimization problem, the typically used optimization method is gradient descent with multiple updates. For a total of \(M\) updates, we repeatedly calculate the gradient of each weight with respect to the minimization objective and update the weights in the opposite direction of the gradient. In its simplest form, the update rule can be expressed as

\[\theta_{t+1}=\theta_{t}-\alpha\nabla_{\theta}\sum_{(x,y)\in\mathcal{D}}l(f_{ \theta_{t}}(x),y), \tag{2}\]

where \(\alpha\) is a scalar and is typically referred to as the learning rate. Here we have denoted the network weights after \(t\) updates as \(\theta_{t}\).
### Definition of the generalized uncertainty

We define the uncertainty of a deep neural network as a function that maps a data example to any real number or vector, namely \(c_{\theta}:\mathcal{X}\times\mathcal{Y}\rightarrow\mathbb{R}^{K}\), where \(c_{\theta}\) means that such a function mapping is defined by the network \(f_{\theta}\). Note that sometimes such a function mapping can take the input only, with the label missing, in which case we denote it as \(c_{\theta}:\mathcal{X}\rightarrow\mathbb{R}^{K}\), with a slight abuse of notation.

We note that such a definition can cover multiple classical definitions of uncertainty. For example, in a multi-class classification setting where each input is associated with a label selected from a set of \(K\) classes, a deep neural network's confidence of its prediction is simply defined as the maximum probability mass in its output vector, namely \(c_{\theta}(x)=\max_{k}f_{\theta}(x)[k]\), where \(f_{\theta}(x)[k]\) denotes the \(k\)-th entry of the prediction vector \(f_{\theta}(x)\). Here we have in fact interpreted the prediction vector in a probabilistic sense. Let \(\mathbf{1}_{k=k^{\prime}}\in\mathcal{Y}\subseteq\mathbb{R}^{K}\) denotes the vector where only the \(k^{\prime}\)-th entry is \(1\) and others are \(0\), we then have \(\Omega=\{\mathbf{1}_{k=1},\mathbf{1}_{k=2},\cdots,\mathbf{1}_{k=K}\}\) defined as the sample space, and \(f_{\theta}(x)[k^{\prime}]\) denotes the probability measure of the singleton set \(\{\mathbf{1}_{k=k^{\prime}}\}\). One may recognize that this is the standard definition of a categorical distribution.

Note that in order to use the prediction vector as a valid probability measure, it is desired that the prediction vector lies in a \((K-1)\)-dimensional simplex, namely \(f_{\theta}(x)\in\Delta_{K-1}:=\{y\in[0,1]^{K}\mid\|y\|_{1}=1\}\). We will review more typical definitions of the uncertainty of deep neural networks in later sections.

## 3 Uncertainty Estimation of Deep Neural Networks

Standard deep neural networks are usually deterministic inference systems, namely the prediction on a given input will not vary for multiple forward passes. It is possible to inject inherent randomness into a deep model's inference process by specifying a prior distribution over its weights \(\theta\). By the Bayesian theorem, the uncertainty of a prediction can then be captured by the posterior distribution of the prediction conditioned on the model weights. Such a deep neural network variation is called a Bayesian Neural Network (BNN) (Denker et al., 1987; Tishby et al., 1989; Buntine & Weigend, 1991). It is rather obvious that the inference of such neural networks would be computationally expensive, as multiple samplings of the model weights are required for one single inference. There have been a variety of attempts to make BNNs computationally tractable, such as Laplace approximation (Bridle et al., 2011) and Markov chain Monte Carlo (MCMC) methods (Neal, 1995).

In this review, we will focus only on the uncertainty of standard deterministic deep neural networks, while skipping recent works on BNNs. The reasons are two folds. First, in practice, BNNs are still difficult to implement and computationally slow (Lakshminarayanan et al., 2017). Second and more importantly, in this review, we are not seeking the role of uncertainty in the transparency of the model decision process, but rather in aiding the model training. For example, a typical application of uncertainty is to select high-quality unlabeled data that is most relevant to the current task from a large corpus. We will discuss more of such applications in the following sections.

### Classic uncertainty

In Section 2.2, we have mentioned the classic way to interpret the predictive vector of a deep neural network as a probability distribution. In practice, to create a valid probabilistic vector, we often need to apply a non-linear activation function on top of the network outputs. Let the original output vector of a network as \(z\in\mathbb{R}^{K}\), and \(\sigma:\mathbb{R}^{K}\rightarrow[0,1]^{K}\) as a non-linear function. We will then make \(f_{\theta}(x)=\sigma(z)\) for an input \(x\), where \(z\) is often referred as the logits. For example, in a binary classification task, we will use the sigmoid function, namely

\[\sigma(z)=\frac{1}{1+\exp(-z)},\]

and in a multi-class classification task, we will use the softmax function, namely

\[\sigma(z)[k]=\frac{\exp(z[k])}{\sum_{k=1}^{K}\exp(z[k])}.\]

A valid probabilistic vector can be directly interpreted as the uncertainty of the model prediction. One can also transform such an uncertainty vector into a number, which will be particularly handy
in obtaining the ranking of a set of data examples based on an uncertainty measure. Various transformations are used in the literature, typically including maximum probability, entropy, and margin.

* Maximum probability: \(c_{\theta}(x)=\max_{k}f_{\theta}(x)[k]\),
* Entropy: \(c_{\theta}(x)=-f_{\theta}(x)\cdot\log f_{\theta}(x)\),
* Margin: \(c_{\theta}(x)=\max_{k}f_{\theta}(x)[k]-\max_{k\neq k^{\prime}}f_{\theta}(x)[k]\), where \(k^{\prime}=\arg\max_{k}f_{\theta}(x)[k]\).

### Evaluation of classic uncertainty

The desired properties of an uncertainty estimate may vary significantly across the tasks of interest, sometimes even orthogonally. Consequently, a variety of uncertainty evaluation metrics exists in the literature. Here we roughly group them into three types based on the property desired.

**Recovering the true distribution.**  Assuming the data examples are sampled from a joint distribution \(P_{X,Y}(x,y)=P_{X}(x)P_{Y|X}(y|x)\) defined over \(\mathcal{X}\times\mathcal{Y}\). Given any input \(x\), it is desired that the predictive uncertainty, namely the probabilistic vector \(f_{\theta}(x)\) produced by a deep neural network, can recover the true conditional distribution \(P_{Y|X}(y|x)\). Note that such recovery is a stricter concern compared to accuracy (Lakshminarayanan et al., 2017). A network's prediction can be very accurate, yet significantly deviate from the true conditional distribution. A typical example is that the network always outputs the one-hot label on an input \(x\).

To evaluate the quality of the recovery, one can use commonly seen loss functions such as negative log-likelihood (NLL) loss and mean squared error (MSE). Interestingly, it is known in meteorology that these two loss functions have good properties 1, or they are known as proper scoring rules (Gneiting and Raftery, 2007). A proper scoring rule is one loss function where \(l(p,q)\geq l(q,q)\) with equality if and only if \(p=q\). This means that minimizing the distance between the predictive uncertainty and one-hot labels can in fact recover the true conditional distribution. To see that for NLL, we can apply the Gibbs inequality, namely

Footnote 1: MSE is also known as the Brier score in meteorology

\[-\mathbb{E}_{(x,y)\sim P(x,y)}\mathbf{1}_{y}\cdot\log f_{\theta}(x)=-\mathbb{ E}_{x\sim P(x)}P(y|x)\cdot\log f_{\theta}(x)\geq-\mathbb{E}_{x\sim P(x)}P(y|x) \cdot\log P(y|x), \tag{3}\]

where the equality establishes if and only if \(f_{\theta}(x)=P(y|x)\). To see that for MSE, we can decompose the MSE and find that

\[\|\mathbf{1}_{y}-f_{\theta}(x)\|_{2}^{2}=\|\mathbf{1}_{y}-P(y|x)\|_{2}^{2}+\| P(y|x)-f_{\theta}(x)\|_{2}^{2}\geq\|\mathbf{1}_{y}-P(y|x)\|_{2}^{2}, \tag{4}\]

where the equality establishes if and only if \(f_{\theta}(x)=P(y|x)\). Therefore, in practice when there are only one-hot labels available, we can still use NLL or MSE to quantify the quality of the uncertainty in terms of its recovery to the true conditional distribution.

**Calibration.**  Loosely speaking, calibration of deep neural networks implicates the network uncertainty should reflect the probability that it makes errors (Guo et al., 2017). Here we are only interested in the network's argmax prediction, which we denote as \(y_{\theta}=\arg\max_{k}f_{\theta}(x)[k]\) for simplicity. We are also only interested in the uncertainty as a real number between \(0\) and \(1\), which reflects the probability of the pointwise prediction \(y_{\theta}\) being correct. Usually, this is simply the maximum probability, namely \(c_{\theta}(x)=\max_{k}f_{\theta}(x)[k]\). Formally, calibration then desires that (Guo et al., 2017)

\[P(y_{\theta}=y\mid c_{\theta}(x)=p)=p,\ \forall\ p\in[0,1]. \tag{5}\]

Here the left denotes the accuracy of the network prediction on all examples where the network reports uncertainty of \(p\), and the right is the value of the uncertainty. Therefore, calibration means that the uncertainty of a prediction should genuinely match the probability of correctness of such prediction. It may help the understanding of calibration if we interpret the probability \(P\) as the limit of the frequency. Therefore, an alternative way to formalize calibration is (Kuleshov et al., 2018),

\[\lim_{N\rightarrow\infty}\frac{\sum_{i=1}^{N}1(y_{\theta}=y_{i})\cdot 1(c_{ \theta}(x_{i})=p)}{\sum_{i=1}^{N}1(c_{\theta}(x_{i})=p)}=p, \tag{6}\]

where \(1(\cdot)\) is the indicator function.
A legacy issue is that, calibration of deep neural networks is in fact a weaker requirement of the model uncertainty compared to the definition of calibration in standard statistical terminology (Zadrozny and Elkan, 2001), which can be denoted as

\[P(y\in\cdot|f_{\theta}(x)=\mathbf{p})=\mathbf{p},\ \forall\ \mathbf{p}\in\Delta_{K-1}, \tag{7}\]

namely for any predictive distribution of the network, the label should distribute exactly as that predictive distribution. Note that, although a true model producing the true conditional distribution is certainly calibrated, a (statistically) calibrated model does not necessarily have to recover the true conditional distribution and a model that is not close to the true model can nevertheless be calibrated (Vaicenavicius et al., 2019).

To measure the uncertainty quality in terms of calibration, one can use the difference in expectation between the accuracy and the uncertainty, namely

\[\mathbb{E}_{p}\left[|P(y_{\theta}=y\mid c_{\theta}(x)=p)-p|\right]. \tag{8}\]

In practice, one can report the Expected Calibration Error (ECE) (Naeini et al., 2015), which approximates the expectation by binning. Specifically, the predictions on all test examples are partitions into several equally-spaced bins, where predictions with similar uncertainty will be assigned into the same bin. We can then approximate \(P(y_{\theta}=y\mid c_{\theta}(x)=p)\) in Equation (8) by the action of correct predictions in each bin, and approximate \(p\) in Equation (8) by the average uncertainty in this bin.

When the calibration of all-class predictions instead of the argmax prediction is of interest, one can also use the Static Calibration Error (SCE) (Nixon et al., 2019) to quantify the uncertainty quality. All-class calibration measures are often more effective in assessing the calibration error (Nixon et al., 2019). Other variation includes the adaptive Expected Calibration Error (aECE) (Nixon et al., 2019), which partitions the predictions into several bins with an equal number of predictions in each bin. This can be more robust to the number of bins (Patel et al., 2021), since the uncertainty distribution is often far from a uniform one (Guo et al., 2017), and the number of bins is critical in evaluating the calibration genuinely (Kumar et al., 2019).

Ordinal ranking.In many practical settings, the absolute distance between model uncertainty and the probability of correctness is often not necessary. Instead, the ranking of a set of predictions based on the uncertainty measure is more important. The major objective here is to distinguish correct from incorrect predictions. Therefore it is desired that correct predictions have higher confidence estimates than incorrect predictions. Formally, a prefect ordinal ranking means that (Moon et al., 2020)

\[c_{\theta}(x_{i})\leq c_{\theta}(x_{j})\Longleftrightarrow P(y_{\theta,i}=y_{ i}|x_{i})\leq P(y_{\theta,j}=y_{j}|x_{j}). \tag{9}\]

To measure the uncertainty quality in terms of ordinal ranking, one can specify an uncertainty threshold, such that predictions with uncertainty above this threshold are regarded as correct predictions. However, this often rises the problem of a trade-off between false negatives and false positives (Hendrycks and Gimpel, 2017). For a threshold-free evaluation, one can use metrics such as the Area Under the Receiver Operating Characteristic curve (AUROC) (Davis and Goadrich, 2006), the Area Under the Precision-Recall curve (AURC) (Manning and Schutze, 2002) and the Area under the Risk-Coverage curve (AURC) (Geifman et al., 2019). The underlying idea of all these measures is to aggregate the accuracy under all possible thresholding of the set of predictions.

Ordinal ranking has a wide variety of applications in practice. For example, uncertainty with accurate ranking can effectively identify those examples that come from a distribution substantially different from the distribution that the model is trained on. Such examples are known as the out-of-distribution (OOD) examples. Ordinal ranking is also important in active learning (Settles, 2009), where the goal is to build a model knowing which examples should be labeled to improve its performance. Quality uncertainty ranking can thus greatly reduce human labeling efforts. Ordinal ranking is also crucial in selective classification (Geifman and El-Yaniv, 2017) or failure prediction (Hendrycks and Gimpel, 2017; Hecker et al., 2018), where the goal is to reject some predictions in test time that are likely to be incorrect. The rejected examples can be passed on to backup inference systems or humans, such that the overall prediction accuracy can be greatly improved. We will discuss more applications in later sections and frequently revisit the ranking measure of uncertainty.

### Problems and improvement of classic uncertainty

It is well-known that the classic uncertainty of deep neural networks may have major drawbacks. It may be poorly calibrated (Guo et al., 2017), yields inconsistent ranking (Corbiere et al., 2019),
and is vulnerable to perturbations such as adversarial attack (Szegedy et al., 2014; Goodfellow et al., 2015) and dataset shifts (Hendrycks and Gimpel, 2017; Ovadia et al., 2019).

To overcome these drawbacks of classic uncertainty, a variety of methods have been proposed, which can be roughly divided into two veins. The first vein is called post-processing, namely the uncertainty is rectified after a model is trained. In this case, a validation set is often needed. The second vein can be broadly referred to as regularization, namely the training process is modified to take into consideration. not only the accuracy but also the uncertainty.

**Post-processing.**  The very first and also the simplest post-processing method for deep neural networks is probably temperature scaling (Guo et al., 2017). The idea is to insert a hyperparameter called temperature in the softmax function of a trained model and fine-tune it on a validation set. The softmax function now becomes

\[\sigma(z;T)[k]=\frac{\exp(z[k]/T)}{\sum_{k=1}^{K}\exp(z[k]/T)}. \tag{10}\]

When \(T\) is larger, the new predictive distribution will become softer (higher entropy), which may alleviate the typical problem of deep neural network's uncertainty, namely being over-confident and inappropriately close to the one-hot label. Temperature scaling has been shown to be quite effective in improving the uncertainty, particularly in terms of calibration, outperforming more sophisticated calibration methods such as histogram binning (Zadrozny and Elkan, 2001), Isotonic regression (Zadrozny and Elkan, 2002) and Platt scaling (Platt, 1999). On top of its simplicity and effectiveness, another reason for the popularity of temperature scaling is probably that temperature scaling will preserve the model's accuracy albeit improving the uncertainty, because scaling the logits by a scalar will not change the argmax of the predictive vector. Note that despite its success in calibration, temperature scaling cannot improve the ordinal ranking of the model uncertainty. The reason is similar as the logit scaling is universal to all examples.

Many variations of temperature scaling have been proposed to further enhance its effectiveness. For example, one can perform the temperature scaling for each class in a one-vs-all manner, despite sacrificing the accuracy since the argmax label is no longer preserved (Kull et al., 2019). Multiple temperature scaling methods can be ensembled to achieve better uncertainty quality (Zhang et al., 2020). One can also combine temperature scaling with other calibration methods such as histogram binning to get a theoretical guarantee on the calibration error (Kumar et al., 2019). Liang et al. (2018) observed that adding small adversarial perturbation to the input after temperature scaling can further improve the ranking of the uncertainty and thus better separate in- and out-of-distribution examples. When there are data from multiple domains available, one can learn and predict the most proper temperature when encountering an unseen example that is likely shifted from existing distributions (Yu et al., 2022).

**Regularization.**  The standard deep neural network training protocol may already have some specific design that favors the learning of uncertainty. For example, as also mentioned before, the typically used loss functions such as NLL and MSE are in fact proper scoring rules, which can recover the true conditional distribution when minimized (Lakshminarayanan et al., 2017). The uncertainty learned by standard network training may be particularly effective in terms of ranking, and can serve as a strong baseline for detecting misclassified and OOD examples (Hendrycks and Gimpel, 2017). Several simple regularization methods commonly used for improving performance have been shown to effectively improve the model uncertainty as well. These include early stopping or more advanced instance-wise early stopping (Geifman et al., 2019), label smoothing (Muller et al., 2019), focal loss (Mukhoti et al., 2020), dropout (Srivastava et al., 2014) and data augmentation methods such as mixup (Thulasidasan et al., 2019) and Augmix (Hendrycks et al., 2020).

\[\lambda\sim Beta(\alpha,\alpha)\]

More advanced methods for improving performance are also demonstrated to improve uncertainty. Adversarial training (Goodfellow et al., 2015; Kurakin et al., 2017; Madry et al., 2018), originally designed to improve the robustness of deep neural networks against adversarial examples (Goodfellow et al., 2015), have been shown to improve the uncertainty (Lakshminarayanan et al., 2017). Knowledge distillation can also be viewed as a regularization method with the aid of auxiliary models and has been shown to improve uncertainty in a diverse form, such as self-distillation (Kim et al., 2021), dropout distillation (Bulo et al., 2016;
Gurau et al., 2018) and ensemble distillation (Mariet et al., 2020). Recent years have seen a boom in pre-training, which trains the model on a large corpus without any labels, or in a so-called self-supervised scheme. Pre-training can benefit the learning of "universal representations" that transfers to multiple domains (Rebuffi et al., 2017), and can be viewed as a better initialization of a deep neural network. Therefore, it is not surprising that pre-training can improve the model uncertainty and robustness, even when the second-stage learning (or fine-tuning) is happening on a sufficiently large dataset where pre-training fails to improve the performance significantly compared to directly training on it (Hendrycks et al., 2019).

There are also a variety of regularization methods specifically designed for uncertainty learning, such as penalizing low-entropy predictive distribution in the training objective (Pereyra et al., 2017), interpolating the predictive distribution and the one-hot label using uncertainty score (Devries and Taylor, 2018), incorporating OOD examples into training and enforcing the model to produce low-confidence predictions on them (Lee et al., 2018), variance-weighted variation of label smoothing (Seo et al., 2019). Moon et al. (2020) shows that penalizing the ranking difference between the uncertainty yielded by predictions at one training step and the moving-averaged predictions at multiple training steps can improve uncertainty learning, particularly effective for ordinal ranking. Maddox et al. (2019) shows that the mean and variance of network weights across multiple training steps can serve as a good prior for their uncertainty distributions, thus building an efficient approximation for BNNs. One can also utilize an alternative network or alternative network modules to specialize in uncertainty learning while leaving the original network intact (Corbiere et al., 2019; Geifman and El-Yaniv, 2019).

Note that these regularization methods are not necessarily orthogonal to each other, and may even hurt the uncertainty or accuracy when combined together. For example, it is well-known that label smoothing and knowledge distillation are not compatible with each other (Muller et al., 2019). And ensembling (see Section 3.4) combined with data augmentation methods such as mixup can also hurt the model calibration (Wen et al., 2021).

### Ensemble uncertainty

In this section, we specifically focus on those methods that achieve better uncertainty quality by aggregating multiple classic uncertainty estimates. In essence, any randomness or perturbation in the input, sampling, weights, and optimization of deep neural networks during training or inference can be utilized to generate multiple uncertainty estimates for aggregation (Renda et al., 2019). We thus roughly partition the diverse ensembling methods into three families based on the origins of such randomness or perturbation.

**Model ensemble.** Probably the most well-known uncertainty ensemble method is Monte-Carlo Dropout (MC-dropout) (Gal and Ghahramani, 2016). The idea is to utilize dropout to randomize the inference process of a network and average multiple stochastic predictions of one example to generate a better uncertainty estimate. Despite its simplicity, MC-dropout is shown to be akin to the Gaussian process and thus can be an efficient approximation of BNNs (Gal and Ghahramani, 2016), and has been widely used in practice. Bachman et al. (2014) generalized such an idea using any network modules to randomize the inference process.

Another well-known ensemble method is typically referred to as deep ensemble (Lakshminarayanan et al., 2017). Here the randomness originates from the initialization of the deep neural networks, which is typically sampled from Gaussian distributions. One can thus train multiple deep neural networks on the same training set, and average their predictive distributions to obtain a better uncertainty estimate. It is possible to further promote the diversity of deep ensemble by combining the randomness in the data sampling process, e.g., bagging and boosting (Livieris et al., 2021). But in general cases, such a combination may not necessarily improve the uncertainty estimates and sometimes hurts the performance (Lee et al., 2015; Lakshminarayanan et al., 2017). Deep ensemble is widely used in practice, but may suffer from both increased training cost and inference cost. To reduce the inference cost, one can distill the knowledge of the ensemble into a single and small network (Hinton et al., 2015; Mariet et al., 2020; Nam et al., 2021). To reduce the training cost, instead of training multiple networks, one can also only train multiple modules and share other modules. For example, Kim et al. (2018) shows ensemble multiple attention modules trained with different attention masks can improve the uncertainty for image retrieval. Wen et al. (2020) generalizes such an idea by composing each
weight matrix in a network based on the Hadamard product between a shared matrix among all ensemble members and a low-cost matrix unique to each member.

Input ensemble.We have already mentioned the idea of using bagging or boosting to promote diversity in ensemble. This on its own can in fact be viewed as input ensemble, namely the randomness originates from either the sampling of the inputs, which can be utilized in training, or perturbation and data augmentation of the inputs, which can be utilized in both training and inference. For example, during training, Nanni et al. (2019) utilizes data augmentation to build an ensemble for bioimage classification while Guo & Gould (2015) utilizes data augmentation for deep ensemble in object detection.

During inference, aggregating by data augmentation is even more widely used, particularly in medical image processing (Wang et al., 2018, 2019). Such a technique is also commonly referred to as test-time augmentation (Ayhan & Berens, 2018). Empirical analyses found that test-time augmentation is quite sensitive to the data augmentation being used (Shanmugam et al., 2020). Methods are thus proposed to learn appropriate data augmentation, for example, that customizes for each test input individually (Kim et al., 2020).

Optimization ensemble.The randomness of the optimization of a deep neural network can also be utilized to generate an ensemble. Snapshot ensemble (Huang et al., 2017) utilizes the fact that the weight landscape of a deep neural network is non-convex and the weights may traverse multiple local minima during optimization. They thus propose repeatedly decreasing and increasing the learning rate to let the optimization converge multiple times. Each converged network checkpoint can then serve as a member of the ensemble. Yang & Wang (2020) adapts such an idea to adaptive learning rate schedulers. Fast Geometric Ensembling (FGE) (Garipov et al., 2018) and Stochastic Weight Averaging (SWA) (Izmailov et al., 2018) share a similar idea with snapshot ensemble, albeit the specific strategy to sample checkpoints along the training trajectory may differ. Hyperparameter ensemble (Wenzel et al., 2020) is a general method for optimization ensemble which uses AutoML to search for multiple hyperparameters for ensembling.

### "Deep" uncertainty

We now move from the classic definition of uncertainty, namely predictive distribution and its variants, to a more generalized definition of uncertainty, especially those that are unique to the training or inference process of deep neural networks. We roughly partition these uncertainty measures into two groups, namely those based on inference dynamics, and those based on training dynamics.

Inference dynamics.During the inference of deep neural networks, typically only the outputs are desired. However, it is possible to mine other forms of measures associated with the network inference process as uncertainty. For example, Oberdiek et al. (2018) and Lee & AlRegib (2020) measure the uncertainty of a prediction using gradient information. When predicting on a single example, the gradients of the network weights with respect to the loss are calculated, where the label is simply the predicted class. The uncertainty can then be defined as the norm of the gradients.

When the training set or some training examples are available during inference, one can measure the uncertainty by quantifying the "similarity" between the test example and the training examples (Raghu et al., 2019; Ramalho & Corbalan, 2020). In essence, such methods build a density estimation in the input space and thus can reject those test inputs that are likely to be off-distribution. van Amersfoort et al. (2020) adapts this idea by maintaining only a set of representative training examples (or their feature vectors) called centroids. The uncertainty is then quantified as the distance between the test input and the centroid that is closest to it. Note that such uncertainty measures dispense with the need to predict the label. Alternatively, Jiang et al. (2018) defines the uncertainty as the ratio between the distance from the test input to the closest centroid and the distance from the test input to the centroid associated with the class predicted by the model, which can be more robust. These methods may be inherently connected to few-shot learning methods such as ProtoNet (Snell et al., 2017) where the training set is also directly used to help the inference.

Finally, there exist some intriguing behaviors of the inference process of deep neural networks that can be leveraged to quantify the uncertainty. Baldock et al. (2021) observed that through the forward propagation in a deep neural network with multiple layers, the prediction of some examples may already be determined after only a few layers. Here the intermediate predictions are made by k-nearest neighbors classifiers on the hidden representations. They thus define an uncertainty measure
called Prediction Depth (PD). It is shown that the prediction depth may be closely correlated with the margin of the final predictive distribution and examples with large prediction depth may be more difficult. Second, it is known that the inference of deep neural network is vulnerable to adversarial perturbation. It is observed that the predictions on some examples are more resistant to adversarial perturbation. Therefore, one can define the smallest perturbation size required to change the model's prediction as an uncertainty measure (Carlini et al., 2019). Such a metric, typically referred as minimum adversarial perturbation (Carlini and Wagner, 2017) or adversarial input margin (Baldock et al., 2021), may also be closely correlated with the uncertainty defined on the predictive distribution.

**Training dynamics.**  Deep neural networks may exhibit even more intriguing behaviors during training. It is well-known that deep neural networks can perfectly fit even pure noise (Zhang et al., 2017), which raises the question of whether deep networks simply "memorize" the training set even on real datasets. However, through a careful investigation of the predictions on individual training examples, Arpit et al. (2017) finds that data examples are not learned at the same pace during training. Those real data examples are learned first, while those random data, either with random input or random labels, are learned late. Further, they also found that simple data examples are learned earlier than those difficult data examples. These observations demonstrate that deep neural networks are not simply memorizing data since they appear to be aware of the content and semantics. Hacohen et al. (2020) further shows such a learning order of training examples is consistent across different random initializations of a network and different model architectures. Even more intriguingly, they find that such a consistent learning order is not observed for non-parametric classifiers such as AdaBoost. They also observed that when trained on synthetic datasets where the images are different rotation or colorization of Gabor patches, such a consistent learning order disappears as well. They thus hypothesize that such an intriguing behavior may originate from the interplay between deep neural networks and natural datasets with recognizable patterns and semantics.

Toneva et al. (2019) observed that certain training examples are frequently forgotten during training, which means that they can be first predicted correctly, then incorrectly. The frequency of such forgotten events is shared across different neural architectures. When removing those least forgettable examples from training, model performance can be largely maintained Nevertheless, Dong et al. (2021) shows an opposite trend exists in adversarial training, where those most forgettable examples 2 may be removed without degrading performance, and sometimes even improving it. The variance of the gradient of a data example during training is also shown to be strongly correlated with its difficulty (Agarwal and Hooker, 2022).

Footnote 2: Here a correct prediction is defined under adversarial perturbation.

## 4 Utilize Uncertainty for Better Performance

Starting from this section, we demonstrate that the uncertainty of deep neural networks can be utilized to improve the robustness and efficiency of learning systems in a variety of realistic applications.

### Uncertainty for robust learning

We first focus on the application of uncertainty in robust learning. Here we will skip the detection of OOD examples as it is often a standard application of model uncertainty. Instead, we will discuss how to utilize uncertainty in learning with noisy labels and adversarially robust learning.

**Learning with noisy labels.**  One straightforward idea for learning with noisy labels is to identify those labels in the training data that are likely to be incorrect. This naturally calls the necessity of uncertainty estimates, which is often referred to as Confidence Learning (CL) (Northcutt et al., 2021) in noisy learning regime. Classic uncertainty can, of course, be utilized to identify noisy labels, but may be inferior since sufficiently trained deep neural networks can memorize the labels and thus be over-confident. To combat this, one can simply perform early stopping to obtain a better uncertainty (Liu et al., 2020). This implicitly leverages the training dynamics of deep neural networks, namely noisy data will be learned late during training. By further combining the observation of prediction depth, namely noisy data will be learned in later layers of a deep neural network, one can early stop different parts of the network at different training checkpoints. In specific, early layers will be trained first and later layers will be progressively trained with few epochs, while the early
layers will be frozen (Bai et al., 2021). Xia et al. (2021) further exploits this idea by dividing all network weights into those that are important for fitting clean labels and those that are important for fitting noisy labels based on gradient norm. The former weights are updated regularly while the latter are simply penalized with weight decay. This can be viewed as early stopping the training of the network in a parameter-wise manner. Han et al. (2020) also considers suppressing the learning on data examples that are likely to have noisy labels during training to avoid memorizing noisy labels.

Instead of seeking better output uncertainty estimates, several methods directly utilize the uncertainty yielded by training dynamics of deep neural networks as a metric to identify noisy labels. For example, Anonymous (2023) proposes using Time-Consistency Prediction (TCP) to select clean data, which is simply the stability of the prediction on an example throughout training. Slightly differently, Pleiss et al. (2020) proposes to use the averaged margin of an example through training to select clean data.

On top of detecting noisy labels, uncertainty estimates are also important in more advanced and sophisticated noisy learning methods. For example, Co-teaching (Han et al., 2018) trains two networks simultaneously where one network is trained on the potentially clean labels selected by its peer network in a mini-batch. A reasonably good uncertainty estimate for noisy labels is necessary here. DivideMix (Li et al., 2020) further develops this idea by using one network to divide the training set into a clean partition and a noisy partition. The peer network is trained on the clean partition, along with the noisy partition without labels in a semi-supervised manner. DivideMix has achieved state-of-the-art on multiple noisy learning benchmarks.

**Adversarially robust learning.** Adversarial training (Goodfellow et al., 2015; Madry et al., 2018) is so far the most effective way to enhance the robustness of deep neural networks against adversarial examples. However, the robust accuracy achieved on small benchmark datasets such as CIFAR-10 (Krizhevsky, 2009) or CIFAR-100 (Krizhevsky, 2009) is still unsatisfactory, not to mention larger datasets such as ImageNet (Russakovsky et al., 2014), especially against those strong adversarial attacks such as AutoAttack (Croce & Hein, 2020). Surprisingly, recent studies found that robustness achieved by adversarial training can be greatly boosted if the deep neural networks are trained on additional data, which is either selected from large unlabeled data corpus (Uesato et al., 2019; Carmon et al., 2019) or simply generated by generative models (Sehwag et al., 2021; Gowal et al., 2021), thus requiring minimal human effort. Because those additional data examples may be far away from the original data distribution, selecting high-quality additional data is demonstrated to be crucial in this process (Uesato et al., 2019; Gowal et al., 2020). The typical metric used to select additional data is the classic uncertainty score yielded by a classifier trained on the in-distribution clean data. Dong et al. (2021) suggests that it may be better to use training stability, namely the frequency of predictions on an example being correct throughout training. However, how to build an uncertainty metric to select high-quality additional data remains an open and important problem.

Some intriguing problems in adversarially robust learning may also require learning good uncertainty estimates. For example, robust overfitting (Rice et al., 2020) is a well-known problem of adversarial training, which refers to the phenomenon that during adversarial training, the robust accuracy on the test set will unexpectedly start to decrease after a certain number of training steps. Such overfitting occurs consistently across different datasets, training settings, adversary settings, and neural architectures. However, when conducting standard training on the same dataset, such an overfitting phenomenon is not observed. Recent work shows that robust overfitting may originate from the label noise implicitly exists in adversarial training, which is induced by the mismatch between the true conditional distribution and the label distribution of the adversarial examples used for training (Dong et al., 2021). Therefore, a straightforward solution to robust overfitting is to recover the true conditional distribution using uncertainty estimates generated by a model, and is demonstrated to significantly alleviate robust overfitting (Chen et al., 2021).

### Uncertainty for efficient learning

In this section, we show that the uncertainty of deep neural networks can be utilized to improve efficiency of deep neural networks. Here we focus on two types of efficiency concerns: data efficiency, namely to reduce the human effort on data annotation in training deep neural networks, and model efficiency, namely to reduce the computation cost of the training and inference of deep neural networks.
#### 4.2.1 Data efficiency

**Semi-supervised learning.** Semi-supervised learning tackles the challenge in real-world applications where only a limited number of labeled data is available, while the vast majority of data is unlabeled. A natural solution to semi-supervised learning is incorporating the labels predicted by a classifier on unlabeled data into training, which are typically referred to as pseudo-labels (Lee, 2013). Such a process can be repeatedly conducted when a better classifier is trained after more pseudo-labeled data is available, which is known as bootstrapping or self-training (McClosky et al., 2006).

However, since the pseudo-labels predicted by a classifier are very likely to be incorrect, it is crucial to define a reliable uncertainty measure to select those correct pseudo-labels. Classic uncertainty can be utilized here but may inevitably suffer from over-confidence (Guo et al., 2017) and memorization Zhang et al. (2017). The recent development of self-training has seen an increasing trend of "uncertainty-aware" methods. For example, instead of using classic uncertainty, Mukherjee & Awadallah (2020) uses MC-dropout to select pseudo-labels for self-training. They also design a loss function that incorporates the uncertainty on the correctness of pseudo-labels into training, where those selected pseudo-labels that are more likely to be correct will be more focused on. Rizve et al. (2021) further shows that self-training using MC-dropout as an uncertainty measure along with other careful designs can compete with much more sophisticated semi-supervised learning methods such as consistency regularization (Laine & Aila, 2016; Tarvainen & Valpola, 2017) and mixed methods (Berthelot et al., 2019), albeit enjoying the advantage that no data augmentation is explicitly required. Zhou et al. (2020) uses the consistency of the model prediction through training as an uncertainty measure in self-training. The hypothesis here is those model predictions that are largely invariant during training are more likely to be correct. This again is reminiscent of the intriguing training dynamics of deep neural networks as mentioned before.

**Weakly-supervised learning.** Weakly-supervised learning is even more challenging than semi-supervised learning in that the limited number of labels are not absolutely correct. In most cases, they are generated by a set of pre-defined rules or provided by annotators without domain expertise, which are referred to as weak supervision. Under such circumstances, a reliable uncertainty estimate becomes more important in not only selecting pseudo-labels predicted by classifiers on the unlabeled set, but also selecting those labels given by weak supervision that are likely to be correct. Mekala et al. (2022) provides a comprehensive analysis of uncertainty estimates in weakly-supervised text classification. They found that among multiple uncertainty measures including classic uncertainty, prediction stability and MC-dropout, the learning order performs the best for selecting pseudo-labels given by weak supervision. As mentioned before, the learning order here refers to the consistent order of learning real and noisy data by deep neural networks during training. Because incorrect pseudo-labels are learned late by the model, the epoch at which the model prediction matches the pseudo-label can be an effective metric to distinguish correct and incorrect labels.

#### 4.2.2 Model efficiency

**Model compression and Knowledge distillation.** To excel in realistic tasks, deep neural networks often have to be excessively large in capacity. This brings significant computation burden in both training deep neural networks and using deep neural networks for predictions. How to compress a large deep neural network while maintaining its performance is thus gaining increasing attention. One well-known method to compress deep neural networks is knowledge distillation (Hinton et al., 2015), namely a small network called student is trained using the predictions provided by a large network called teacher, rather than using the original labels in the training set. Despite its success, why teacher predictions can help student learning has always been a mystery. A recent finding, that the student predictions on the training or test set can often disagree with the teacher predictions on a large number of examples (Stanton et al., 2021), further mystifies knowledge distillation.

Toward better understanding and improving knowledge distillation, a significant effort in theoretical analyses has been made in recent works. In specific, Menon et al. (2021) shows that the predictive distribution provided by the teacher can improve the generalization of students because the predictive distribution is a better approximation to the true conditional distribution than one-hot labels, where true conditional distribution as supervision can reduce the variance. Dao et al. (2021) shows that the distance between teacher predictions and the true conditional distribution can directly bound the student accuracy. Based on this understanding, to improve knowledge distillation we essentially
require the teacher to learn better uncertainty estimates in terms of its recovery of the true conditional distribution. Recent work has thus proposed to directly optimize the teacher to learn the true conditional distribution, which is dubbed as student-oriented teacher training and has achieved better student performance Dong et al. (2022).

**Adaptive inference time.**  Deep neural networks often consist of a great many layers. The inference process can thus be computationally prohibitive as the calculation of each layer has to be made sequentially, one after another. An idea to reduce the inference cost is to early stop the inference process of some examples when the outputs of the intermediate layers are already informative enough to make predictions, which is known as adaptive inference time in sequence processing and classification (Graves, 2016). Such a strategy leverages the inference dynamics of deep neural networks where easy examples may have a small prediction depth.

To ensure an accurate early stopping, a reliable uncertainty estimate is important here to determine when the early predictions are likely to be correct. The entropy of the predictive distribution at early classification heads is widely used in adaptive inference methods across applications in computer vision and natural language processing, albeit the specific designs of the network architecture or training strategies differ. BranchyNet (Teerapititayanon et al., 2016) inserts multiple early-exit classification heads between intermediate layers and trains the network to minimize the weighted sum of the loss functions defined at all classification heads. Multi-Scale DenseNet (MSDNet) (Huang et al., 2017) refines this idea by altering the network architecture such that feature representations at multiple scales can be utilized jointly to determine an early exit. In sequence classification where transformers dominate, adaptive inference time can be built into the network architecture (Dehghani et al., 2018; Xin et al., 2020). FastBert (Liu et al., 2020) improves the early-exit accuracy by introducing self-distillation on intermediate classification heads. Schwartz et al. (2020) improves the uncertainty estimate for early exits by using temperature scaling to calibrate the predictive distribution and achieves a better speed-accuracy trade-off.

## 5 Conclusion

In this survey, we review a wide spectrum of uncertainty measures we can define for deep neural networks. These include the classic definitions of uncertainty such as those based on the predictive distribution, and those definitions of uncertainty that are closely connected to the training and inference dynamics of deep neural networks. We show that these uncertainty measures can be leveraged in realistic applications across computer vision and natural language processing, to improve the robustness and efficiency of learning systems. We believe there are more scenarios where reliable uncertainty estimates are crucial to the performance. We also believe the increasingly popular use cases of uncertainty estimates beyond interpretability and transparency will in turn facilitate more opportunities in uncertainty learning of deep neural networks.
