Nonparametric Uncertainty Quantification for Single Deterministic Neural Network
Abstract
This paper proposes a fast and scalable method for uncertainty quantification of machine learning models’ predictions.
First, we show the principled way to measure the uncertainty of predictions for a classifier based on Nadaraya-Watson’s nonparametric estimate of the conditional label distribution.
Importantly, the proposed approach allows to disentangle explicitly aleatoric and epistemic uncertainties.
The resulting method works directly in the feature space.
However, one can apply it to any neural network by considering an embedding of the data induced by the network.
We demonstrate the strong performance of the method in uncertainty estimation tasks on text classification problems and a variety of real-world image datasets, such as MNIST, SVHN, CIFAR-100 and several versions of ImageNet.
Introduction
In many machine learning applications, it is crucial to complement model predictions with uncertainty scores that reflect the degree of trust in these predictions.
The total uncertainty of a prediction sums from two uncertainty types, arising from different sources: aleatoric and epistemic [14, 33].
The former reflects the irreducible noise and ambiguity in the data due to class overlap, while the latter is related to the lack of knowledge about model parameters and can be reduced by expanding the training dataset.
Disentangling epistemic uncertainty can help to identify out-of-distribution (OOD) data or to spot instances important for annotation during active learning [22].
The areas with high aleatoric uncertainty might contain some incorrectly labeled instances.
If we quantify both types of uncertainty well, we can effectively abstain from predictions in unreliable areas and address a decision to a human expert [18], which is important in safe-critical fields, such as medicine [53], autonomous driving [43, 20], and finance [6].
There is no universally accepted uncertainty measure, and diverse, often heuristic treatments are used in practice.
For this purpose, one simply could use maximum softmax probabilities of deep neural network (NN).
However, MaxProb represents only aleatoric uncertainty, and the resulting measure is notorious to be overconfident in data areas the model did not see during training [59].
Methods based on ensembling [37] or Bayesian techniques [21] can capture both types of uncertainty and yield more
[Figure]
reliable uncertainty estimates (UEs) 1 .
However, along with that, they introduce large computational overhead and might require big modifications to a model architecture and a training procedure.
Recently, a series of UE methods based on a single deterministic neural network model has been developed [41, 69, 46, 70].
The main idea behind these methods is to leverage geometrical proximity of instances in a vector space of neural network hidden representations that capture semantic relationships between instances in the input space.
Such methods are very promising since they are computationally efficient and usually do not require big changes in network architectures and training procedures, which gives them versatility.
Many of these methods rely on the assumption that (conditionally on the class) training instances are distributed normally in the latent space of a trained neural network [70, 41].
However, this assumption does not always hold.
For example, a border between classes might be more complex, as well as the border between the in-domain and the out-of-domain region.
This happens when training is accomplished in a low-resource regime with small amounts of labeled instances.
Another problem is that some methods are hard to train and the model performance can substantially deteriorate without proper hyperparameter tuning.
Finally, some methods require computing the covariance matrix of training data [41].
This operation might be computationally unstable if the training dataset is not large enough.
In this work, we propose a new principled approach to UE that overcomes these limitations and demonstrates very robust performance both in low-resource and in high-resource regimes.
We suggest to look at the pointwise Bayes risk (probability of the wrong prediction) as the natural measure of the model prediction uncertainty at a particular data point.
Then we consider the NadarayaWatson estimator of the conditional label distribution.
Its asymptotic Gaussian approximation allows deriving uncertainty estimate based on the upper bound for the risk.
The resulting Nonparametric
Uncertainty Quantification (NUQ) method is amenable for uncertainty disentanglement (into aleatoric and epistemic) and is implemented in a scalable manner, which allows it to be used on large datasets such as ImageNet.
To illustrate the strong points of the proposed method, we suggest to look at a toy example in Figure 1.
Here, we compare NUQ with MaxProb and DDU [55], one of the strong baselines in deterministic uncertainty estimation aimed at epistemic uncertainty.
MaxProb as a measure of aleatoric uncertainty gives high values only in-between classes while being very confident far from the data.
We also see that for a larger data set of 2000 points NUQ and DDU show similar results.
However, when the neural network model is trained only on 200 labeled instances, DDU scores become very rough.
It cannot spot an unreliable area in-between classes, while the NUQ-based total uncertainty measure does it precisely with high uncertainty score.
Importantly, the presented total uncertainty for NUQ can be also disentangled into aleatoric and epistemic ones.
Below, we give a summary of contributions of this paper.
We develop a new and theoretically grounded method for nonparametric uncertainty quantification (see Section 2), which is (a) applicable to any deterministic neural network model, (b) has an efficient implementation, (c) allows to disentangle aleatoric and epistemic uncertainty, (d) outperforms other techniques on image and text classification tasks (see Section 6).
We formally prove the consistency of the NUQ-based estimator when applied to the problem of classification with the reject option, see Section 4. 3.
We conduct a vast empirical investigation of NUQ and other UE techniques on image and text classification tasks that supports our claims, see Section 6.
Nonparametric Uncertainty Quantification 2.1 Classification under Covariate Shift
In this section and below, for the sake of clarity, we provide derivations for the binary case.
We derive a generalization to a multi-class setting in Supplementary Material (SM), Section A.
Let us consider the standard binary classification setup (
X, Y ) ∈
R
d × { 0 , 1 } with ( X, Y ) ∼ P , where P is a joint distribution of objects and the corresponding labels.
We assume that we observe the dataset D = (cid:8) ( x i , y i ) } Ni =1 of i.i.d.
points from P = P train .
Here, x and y are realizations of random variables X and Y .
The classical problem in statistics and machine learning is using the dataset D , to find a rule ˆ g , which approximates the optimal one: g ∗ = arg min g P ( g ( X ) ̸ = Y ) .
Here, g : R d → { 0 , 1 } is any classifier, and the probability of wrong classification P ( g ( X ) ̸ = Y ) is usually called risk .
The rule g ∗ is given by the Bayes optimal classifier :
[Equation]
where η ( x ) = P ( Y = 1 | X = x ) which is the conditional probability of Y given X
= x under the distribution P .
In this work, we consider a situation when the distribution of the test samples P test is different from the one for the training dataset P train ,
i.e. P test ̸ = P train .
Obviously, the rule g ∗ obtained for P
= P train might no longer be optimal if the aim is to minimize the error on the test data P test ( g ( X )
̸ = Y ) .
In order to formulate a meaningful estimation problem, some additional assumptions are needed.
We assume that the conditional label distribution η ( x ) =
P ( Y | X = x ) is the same under both P train and P test .
This assumption has two important consequences:
The entire difference between P train and P test is due to the difference between marginal distributions of X : p train ( X ) and p test ( X ) .
The situation when p test ( X ) ̸ = p train ( X ) is known as covariate shift .
The rule g ∗ is still valid,
i
e., optimal under P test .
However, while the classifier g ∗ is still optimal under covariate shift, its approximation ˆ g might be arbitrarily bad.
The reason for that is that we cannot expect ˆ g to approximate g ∗ well in the areas where we have few objects from the training set or do not have them at all.
Thus, some special treatment of the covariate shift is required.
2.2 Pointwise Risk and Its Estimation
We consider a classification rule ˆ g ( X ) =
ˆ g D ( X ) constructed based on the dataset D .
Let us start from defining the pointwise risk of a prediction:
[Equation]
where P (ˆ g ( X ) ̸ = Y | X = x ) ≡ P train (ˆ g ( X )
̸ = Y | X = x ) ≡ P test (ˆ g ( X ) ̸ = Y | X = x ) under the assumptions above.
The value
R ( x ) is independent of the covariate distribution p test ( X ) and essentially allows to define a meaningful target of estimation, which is based solely on the quantities known for the training distribution.
Let us note that the total risk value R ( x ) admits the following decomposition:
[Equation]
where R ∗ ( x ) = P ( g ∗ ( X )
̸ = Y | X = x ) is the Bayes risk and ˜ R ( x ) =
P (ˆ g ( X ) ̸ = Y | X = x ) − P ( g ∗ ( X )
̸ = Y | X = x ) is an excess risk.
Here, R ∗ ( x ) corresponds to aleatoric uncertainty as it completely depends on the data distribution.
The excess risk ˜
R ( x ) directly measures imperfectness of the model ˆ g and, thus, can be seen as a measure of epistemic uncertainty.
To proceed, we first assume that the classifier ˆ g has the standard form:
[Equation]
where ˆ η ( x ) = ˆ p ( Y = 1 | X = x ) is an estimate of the conditional density η ( x ) .
For such an estimate, we can upper bound the excess risk via the following classical inequality [15]:
[Equation]
It allows us to obtain an upper bound for the total risk:
[Equation]
where R ∗ ( x ) = min { η ( x ) , 1 − η ( x ) } in the case of binary classification.
While this upper bound still depends on the unknown quantity η ( x ) , we will see in the next section that L ( x ) allows for an efficient approximation under mild assumptions.
2.3 Nonparametric Uncertainty Quantification 2.3.1 Kernel Density Estimate and Its Asymptotic Distribution
To obtain an estimate of L ( x ) and, consequently, bound the risk, we need to consider some particular type of estimator ˆ η .
In this work, we choose the classical kernel-based Nadaraya-Watson estimator of the conditional label distribution as it allows for a simple description of its asymptotic properties.
Let us denote by K h : R d (cid:55)→ R the multi-dimensional kernel function with bandwidth h .
Typically, we consider a multi-dimensional Gaussian kernel, but other choices are also possible.
The conditional probability estimate is expressed as ( y i is either 0 or 1):
[Equation]
The difference between ˆ η ( x ) − η ( x ) for properly chosen bandwidth h converges in distribution as follows (see, e.g. [63]):
[Equation]
where N is the number of data points in the training set, p ( x ) is the marginal distribution of covariates (see details in SM, Section C.3), and σ 2 ( x ) is the standard deviation of the data label at point x .
For binary classification, σ 2 ( x ) = η ( x ) (cid:0) 1 − η ( x ) (cid:1) .
The constant ˜ C = (cid:82)
[ K h ( u )] 2 d u , where u is an integration variable, depends only on the choice of the kernel K h and could be computed in closed form for popular kernels.
See in details in SM, Section C.4.
Now, we are equipped with an estimate of the distribution for ˆ η ( x ) − η ( x ) .
Let us denote by τ ( x ) the standard deviation of a Gaussian from the equation (2):
[Equation]
In the following sections, we first show how to use the obtained property for uncertainty estimation, and then, we show how it can be computed.
2.3.2 Total, Aleatoric, and Epistemic Uncertainty and Their Estimates
In this work, we suggest a particular uncertainty quantification procedure inspired by the derivation above, which we call Nonparametric Uncertainty Quantification (NUQ) .
More specifically, we suggest to consider the following measure of the total uncertainty:
[Equation]
This measure is obtained by considering an asymptotic approximation of the expected value of the total risk upper bound:
[Equation]
in view of (2) and the fact that E | ξ | = std ( ξ ) (cid:113) 2 π for the zero-mean normal variable ξ .
The resulting estimate upper bounds the average error of estimation at the point x and thus indeed can be used as the measure of total uncertainty.
We also can write the corresponding measures of aleatoric and epistemic uncertainties:
[Equation]
Finally, the data-driven uncertainty estimates ˆ U a ( x ) ,
ˆ U e ( x ) and ˆ U t ( x ) can be obtained via plug-in using estimates ˆ η ( x ) , ˆ σ ( x ) , ˆ p ( x ) and, consequently, ˆ τ 2 ( x ) = 1 N ˆ σ 2 ( x ) ˆ p ( x ) ˜ C .
We should note that despite being based on asymptotic approximation, the resulting formulas for uncertainties are very natural and make sense for finite sample size (for example, epistemic uncertainty is proportional to σ 2 ( x ) /p ( x ) ).
We also should note that even known non-asymptotic decompositions for the risk of the NW-estimator still contain the same σ 2 ( x
) /p
( x ) component, see Propositionin [7].
That means that the proposed estimate well captures the general uncertainty trend.
Efficient computation.
We note that computation of the nonparametric estimate (1) involves a sum over the whole available data.
This could be intractable in practice when we are working with large datasets.
However, the typical kernel K h quickly approaches zero with the increase of the norm of the argument: ∥ x − x i ∥ .
Thus, we can use an approximation of the kernel estimate: instead of the sum over all elements in the dataset, we consider the contribution of only several nearest neighbors (see
SM, Section C.2 for details).
It requires a fast algorithm for finding the nearest neighbors.
For this purpose, we use the approach of [51] based on Hierarchical Navigable Small World graphs (HNSW).
It provides a fast, scalable, and easy-to-use solution to the computation of nearest neighbors.
Application to NN and Comparison with Existing Methods.
The resulting NUQ method can be applied to NN in the postprocessing fashion, i.e. one can fit it on top of the embeddings of the trained NN model.
One may wonder about the difference between NUQ and other embedding based methods such as, for example, DUQ [69] or DDU [55].
The difference is twofold: (i) NUQ is based on the rigorous derivation of total, aleatoric, and epistemic uncertainties, while other methods usually consider more heuristic treatment and do not allow for uncertainty disentanglement; (ii)
NUQ considers a more flexible estimator of density in the embedding space that allows to achieve better quality in a small training data regime or for complicated data; see experimental evaluation in
Section 6.
Detailed Algorithmic Description of NUQ Approach
In this section, we provide a detailed algorithmic description of the NUQ approach.
On the training stage, NUQ uses training data embeddings obtained from the pre-trained neural network and builds a
Bayesian classifier based on conditional label probabilities estimated in a non-parametric way:
[Equation]
The bandwidth h is tuned via cross-validation optimizing the classification accuracy on the training data (see SM, Section C.1).
[Table] [Table]
i , y i ) } Ni
[Table]
1 , inference point x , bandwidth h
[Table]
: Prediction ˆ g ( x ) and uncertainty estimate ˆ U t ( x ) { x i k } Kk =1 ← K nearest neighbors of x among { x i } Ni =
[Table]
˜ C,
[Table]
˜ C
= (cid:82) [ K
[Table]
( u )] 2 d
[Table]
On the inference stage, the new object is passed through the neural network and a corresponding embedding is computed.
Then, this embedding is used to compute the uncertainty estimates employing the estimated bandwidth h , see Algorithm 1 that details the computation of all the necessary intermediate quantities as well as the resulting uncertainty estimates based on the embeddings x provided by the neural network.
Algorithm 1 also takes into account the usage of nearest neighbours to speed up the computation of kernel-based estimates.
Finally, the computation of an estimate of the embeddings density ˆ p ( x ) can be done either via the kernel density estimate (KDE) or via the
Gaussian Mixture Model (GMM).
We study the relative benefits of these approaches in Section F.4.
Consistency of NUQ-based Classification with a Reject Option
Above, we obtained uncertainty estimates that characterize the classical risk of a prediction.
However, they are also helpful to solve the formal problem of classification with the reject option.
In this problem, for any input x we can choose either we perform prediction or reject it.
Following [8], we assume that in the case of prediction we pay a binary price depending whether the prediction was correct or not, while in the case of the rejection we pay the constant price λ ∈ (0 , 1) .
For this task, the risk function is
[Equation]
where α ( x ) is an indicator of the rejection.
The minimizer of R λ ( x ) is given by the optimal Bayes classifier g ∗ ( x ) and the abstention function
[Equation]
To approximate α ∗ ( x ) , we utilize hypothesis testing:
[Equation]
We choose the confidence level β > 0 and consider the statistic ˆ U β ( x ) = min (cid:8)
ˆ η ( x ) , 1 − ˆ η ( x ) (cid:9)
+ z 1 − β ˆ τ ( x ) , where z 1 − β is the 1 − β quantile of the standard normal distribution.
The statistic ˆ U β ( x ) combines the plug-in estimate of the Bayes risk min (cid:8)
ˆ η ( x ) , 1 − ˆ η ( x ) (cid:9) and the term z 1 − β ˆ τ ( x ) accounting for the confidence of estimation.
The resulting abstention rule is given by:
[Equation]
Finally, if we consider the pair of kernel classifier ˆ g ( x ) and ˆ α β ( x ) then, we can prove the consistency result for the corresponding risk ˆ R λ ( x ) under standard assumptions on nonparametric densities, see
SM, Section D for details.
Theorem 4.1.
Suppose that assumptions D.1-D.3 hold and p ( x ) > 0 , the bandwidth h → 0 and
Nh d → ∞ as N tends to infinity.
Then, for any β < 1 / 2 :
[Equation]
This result shows the validity of the NUQ-based abstention procedure.
Interesting future work is to obtain a precise convergence rate for the method.
It should be possible based on the finite sample bounds provided in SM, Section D. We also experimentally illustrate the benefits of the proposed estimator in SM, Section D.1.
Related Work
The notion of uncertainty naturally appears in Bayesian statistics [25], and, thus, Bayesian methods are often used for uncertainty quantification.
The exact Bayesian inference is computationally intractable, and approximations are used.
Two popular ideas are the Markov Chain Monte Carlo sampling (MCMC; [57]) and the Variational Inference (VI; [4]).
MCMC has theoretical guarantees to be asymptotically unbiased, but it has a high computational cost.
VI-based approaches [64, 16, 60, 35] are more scalable, they are biased and at least double the number of parameters.
That is why some alternatives are considered, such as the Bayesian treatment of Monte-Carlo dropout [21].
Deep Ensemble [37] is usually considered as a quite strong yet expensive approach.
A series of papers developed ways of approximating the distribution obtained using an ensemble of models by a single probabilistic model [49, 50, 66].
These methods require changing the training procedure and need more parameters to train.
Recently, a series of uncertainty quantification approaches for a single deterministic neural network model was proposed.
In DUQ [69], an RBF layer is added to the network with a custom training procedure to adjust the centroid points (in the embedding space).
The downside of the method is its inability to distinguish aleatoric and epistemic uncertainty.
Another approach to capture epistemic uncertainty was proposed in DDU [55].
It uses a Gaussian mixture model to estimate the density of objects in the embedding space of a trained neural network.
The density values are then used as a confidence measure.
SNGP [46] and DUE [70] are similar but use a Gaussian process as the final layer, requiring estimating covariance with the use of inducing points or RFF expansion.
There is a wide range of papers discussing classification with the reject option.
Most likely, the problem was firstly studied by Chow in [9, 8].
Moreover, in [8], he introduced a risk function used across this paper.
Herbei et al.
[31] studied an optimal procedure for this risk and provided a plug-in rule.
In the following works, empirical risk minimization among a class of hypotheses (see [2, 10]) or other types of risk (see [13, 19, 42]) were investigated.
Besides, a number of practical works have been presented, see, for example, [27, 24, 56].
Experiments
We conduct a series of experiments on image and text classification datasets.
In each experiment, (1) we train a parametric model – a neural network, which we call a base model ; (2) fit NUQ on the training data using the embeddings obtained from the base model.
We use logits as extracted features, if not explicitly stated otherwise.
However, other options are also possible; see Section F.4.
Following SNGP and DDU, we use spectral normalization to train the base model to achieve biLipschitz property and avoid the feature collapse and non-smoothness.
However, NUQ works sufficiently good even without this regularization (see Table 6 in Section F.4).
In all experiments on
OOD detection, we use ˆ U e ( x ) as a measure of uncertainty.
An additional illustrative experiment on detecting actual aleatoric and epistemic uncertainties is presented in SM, Section E.
6.1 How NUQ Affects Model Predictions?
One may ask whether the nonparametric classification method used in NUQ, trained on some embedding from the base model, has any relation to the original neural network.
To reassure the reader, we provide an argument that it well approximates the predictions of the base model and
NUQ-based uncertainty estimates can be used for the base model as well.
Specifically, we compute the agreement between predictions obtained from the Bayes classifier based on kernel estimate (i.e. the one used in NUQ) and base models’ predictions.
This metric formally can be defined as
[Equation]
max j p ( y = j | x i ) (cid:3) .
For CIFAR- (see experiments with this dataset in Section 6.2.1), this metric gives us the agreement of 0.975, which shows that the approach is accurate.
Additionally, we computed the aleatoric uncertainty for
[Table]
The top two results are shown in bold and underline correspondingly.
Evaluation is done for three models trained with different seeds to estimate the standard deviation
Methods a over the compute uncertainty
[Table]
all test objects and found the average percentile of the objects with disagreement is 94.94 ± 4.75.
Thus, disagreement appears for high uncertainty points as expected.
6.2 Image Classification
The main experiments with image classification are conducted on CIFAR-100 [36] and ImageNet [12].
However, several additional experiments with other image classification datasets such as MNIST and
SVHN can be found in SM, Sections F.1 and F.2.
We compare NUQ with popular UE methods, which do not require significant modifications to model architectures and training procedures.
More specifically, we consider Maximum probability (MaxProb) of softmax response of a NN, entropy of the predictive distribution, the Monte-Carlo (MC) dropout [21], an ensemble of models trained with different random seeds (deep ensemble), the Test-Time Augmentation (TTA; [48]), DDU [55], SNGP [46], DUQ [69], and an energy-based approach [47].
For Monte-Carlo dropout, ensembles, and TTA, we first compute average predicted class probabilities and then compute their entropy (see the ablation study in SM, Section F.8).
More details can be found in SM, Section B.
For deep ensembles, we fixed the number of models to 5.
Additional experiments, where we changed the number of models, are presented in SM, Section F.5.
6.2.1 CIFAR-
In this experiment, we test UE methods on the out-of-distribution detection task.
We treat the OOD detection as binary classification (OOD/not-OOD) using only the uncertainty score.
Following the setup from the recent works [69, 70, 65], we use SVHN, LSUN [73], and Smooth [28] as OOD datasets.
The reported metric is ROC-AUC.
As a base model, we train ResNet-50 from scratch on the CIFAR-100 dataset.
NUQ was applied to the features from the penultimate layer of the model, and the density estimate is given by GMM, as it provides the best results (see the results for other choices of hyperparameters in Section F.4).
The results are presented in Table 1.
We can clearly see that NUQ and DDU show close results while outperforming the competitors with a significant margin.
6.2.2 ImageNet
To demonstrate the applicability of NUQ to large-scale data, we evaluate it in the OOD detection task on ImageNet [12].
As OOD data, we use the ImageNet-O [30] and ImageNet-R [29] datasets.
ImageNet-O consists of images from classes not found in the standard ImageNet dataset.
ImageNet-R contains different artistic renditions of ImageNet classes.
In contrast to the previous experiment, we found that for NUQ, it is more beneficial to use KDE as a density estimator p ( x ) , rather than GMM.
Importantly, it took us approximately 5 minutes to receive uncertainties over all ImageNet datasets with a CPU, i.e. our NUQ implementation is readily applicable to large-scale data (see more details in SM, Section F.7).
[Figure]
The results are summarized in Table 2.
We see that for ImageNet-O, many methods show good OOD detection quality, but NUQ achieves an almost perfect result.
For ImageNet-R, simple approaches completely fail while DDU, SNGP, and DUQ perform well, and NUQ shows the best result with a large margin.
Note that unlike in the CIFAR-100 experiment, for ImageNet, NUQ significantly outperforms DDU.
We conjecture that GMM struggles to approximate density here as an embedding structure is much more complicated for ImageNet compared to CIFAR-100 (see some visualizations in Section F.3).
NUQ is beneficial in this case as KDE is much more flexible than GMM and provides a better result.
Additionally, we looked at some typical samples from ImageNet-R with low, moderate, and high levels of uncertainty as assigned by NUQ, see Figure 2.
Here, low, medium, and high uncertainties correspond to 10, 50, and 90% quantiles of the epistemic uncertainty distribution for images from the ImageNet-R dataset.
We observe that uncertainty values correspond well to intuitive degree of image complexity compared to the original ImageNet data.
Some additional ImageNet experiments are presented in SM, Section F.9.
6.3 Text Classification
Experiments on textual data are performed in low-resource settings, where we train models on small subsamples of original datasets.
This regime can be challenging for many UE methods, while NUQ is naturally adapted to it.
We compare NUQ to the best performing methods on image classification:
DDU and deep ensemble, and to the standard baselines: MC dropout and MaxProb.
The methods are evaluated on two tasks: OOD detection and classification with a reject option.
Classification with rejection experiments are conducted on SST-2 [67], MRPC [17], and CoLA [71].
The evaluation metric is RCC-AUC [18].
Experiments with OOD detection are conducted on ROSTD [23] and CLINC [39], which originally contain instances marked as OOD, and a benchmark composed from SST-2 (in-domain), 20 News Groups [38], TREC-10 [44, 32], WMT-16 [5], Amazon [52] (sports and outdoors categories), MNLI [72], and RTE [11, 1, 26, 3], where SST-2 is used as an in-domain dataset, while the rest as OOD datasets.
The final score is averaged across all OOD datasets.
Evaluation metric is ROC-AUC as in the image classification task.
The dataset statistics are presented in SM, Section G.
We use a pre-trained ELECTRA model with 110 million parameters.
The features for NUQ and
DDU are taken from the penultimate classification layer.
The details of the model, hyperparameter optimization, and UE methods are presented in SM, Section G.
6.3.1 Classification with a Reject Option
Figure 3 presents the results for classification with rejection.
For the MRPC dataset, we can note that NUQ, SNGP, and MC dropout show similar results to the MaxProb baseline.
DDU stands out, demonstrating substantially worse performance in settings with small amount of training data.
A similar dynamics for DDU can be noted on the CoLA dataset, where it works substantially worse than the baseline when only 1% of the training data is available.
SNGP in this experiment manages to reach other methods only when 10% of training data is unlocked.
On contrary, NUQ is always on par or better than the baseline outperforming all other computationally efficient methods and has similar performance as computationally expensive MC dropout.
[Figure] [Figure]
works similar to SNGP and DDU, substantially outperforming the MaxProb baseline, and MC dropout in the extremely low resource setting.
Starting from 1.5%, all methods work similarly with small advantage over the baseline.
Overall, we can conclude that in the settings with a small amount of training data, NUQ can be the best choice for estimating uncertainty for the classification with a reject option: it works similar to other methods when there is much training data and does not deteriorate in the low-resource regime, demonstrating much better results than others.
SNGP is able to approach NUQ on SST-2.
However, its performance is not stable, which is illustrated by poor results on CoLA.
DDU sometimes fails to outperform the baseline with small amount of training data, which might be due to its reliance on the assumption that training data has a Gaussian distribution, which does not hold in this setting.
6.3.2 Out of Distribution Detection
Figure 4 presents the results of OOD detection.
We see that NUQ confidently outperforms MC dropout on all datasets and outperforms DDU on ROSTD and CLINC.
This is especially notable for extremely low-resource settings.
SNGP has some advantage over NUQ on ROSTD, but it substantially falls behind on CLINC.
Moreover, unlike SNGP, NUQ always outperforms the MaxProb baseline, therefore, it might be a better choice for OOD detection in low-resource regimes.
Finally, for ROSTD and CLINC datasets, DDU works poorly, sometimes failing to outperform the MaxProb baseline, which stems from the incorrect assumption about the Gaussian distribution of training data.
Conclusions
This work proposes NUQ, a new principled uncertainty estimation method that applies to a wide range of neural network models.
It does not require retraining the model and acts as a postprocessing step working in the embedding space induced by the neural network.
NUQ significantly outperforms the competing approaches with only the recently proposed DDU method [55] showing comparable results.
Importantly, in the most practical example of OOD detection for ImageNet data, NUQ shows the best results with a significant margin.
NUQ is also superior to DDU and other methods on text classification datasets in both OOD detection and classification with rejection.
The code to reproduce the experiments is available online at https://github.com/stat-ml/NUQ .
We hope that our work opens a new perspective on uncertainty quantification methods for deterministic neural networks.
We also believe that NUQ is suitable for in-depth theoretical investigation, which we defer to future work.
Acknowledgements.
The research was supported by the Russian Science Foundation grant 20-71-
Checklist
The checklist follows the references.
Please read the checklist guidelines carefully for information on how to answer these questions.
For each question, change the default [TODO] to [Yes] , [No] , or [N/A] .
You are strongly encouraged to include a justification to your answer , either by referencing the appropriate section of your paper or providing a brief inline description.
For example:
• Did you include the license to the code and datasets?
[Yes] See Section ... •
Did you include the license to the code and datasets?
[No] The code and the data are proprietary.
• Did you include the license to the code and datasets?
[N/A]
Please do not modify the questions and only use the provided macros for your answers.
Note that the
Checklist section does not count towards the page limit.
In your paper, please delete this instructions block and only keep the Checklist section heading above along with the questions/answers below.
For all authors... (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope?
[Yes] (b) Did you describe the limitations of your work?
[Yes] (c) Did you discuss any potential negative societal impacts of your work?
[No] Our proposed method is widely applicable, almost any modern neural network can be equipped with this mechanism.
Potential social impact will highly depend on the specific domain and task.
(d) Have you read the ethics review guidelines and ensured that your paper conforms to them?
[Yes] 2.
If you are including theoretical results... (a) Did you state the full set of assumptions of all theoretical results?
[Yes] (b) Did you include complete proofs of all theoretical results?
[Yes] Proofs for our results are in Supplementary Material, see Section D 3.
If you ran experiments... (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)?
[Yes] We provide the link to our code in Conclusion.
(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)?
[Yes] We discuss this in Supplementary Material, Sections B and G (c)
Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)?
[Yes] (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)?
[No] It is not included in the main paper, but will be addressed in Supplementary material.
If you are using existing assets (e.g., code, data, models) or curating/releasing new assets... (a) If your work uses existing assets, did you cite the creators?
[Yes] We provide references to the datasets in the 6 section.
For our comparisons with existing approaches we have used the author’s implementations that were provided in the respective original papers that we cite.
(b) Did you mention the license of the assets?
[No] We use only open source code and datasets.
(c) Did you include any new assets either in the supplemental material or as a URL?
[Yes] We provide the link to our code in Conclusion.
(d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating?
[N/A] All the assets used are free for research purposes.
(e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content?
[No] We use publicly available datasets to benchmark our results and show only numeric values and abstract plots.
To the best of our knowledge we have not exposed any personal information or offensive content.
If you used crowdsourcing or conducted research with human subjects... (a) Did you include the full text of instructions given to participants and screenshots, if applicable?
[N/A] (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable?
[N/A] (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation?
[N/A]
A Multiclass Generalization for Uncertainties
In this section we show, how our method can be generalized from binary classification to multiclass problems.
Consider data pairs ( X, Y ) ∼ P .
Now, X ∈ R d and Y ∈ { 1 , . .
, C } , where C is the number of classes.
We also denote η c ( x ) =
P ( Y = c
| X = x ) .
Let us start with the Bayes risk:
[Equation]
where g ∗ ( x ) := arg max c η c ( x ) is the Bayes optimal classifier.
Let us further move to the excess risk and denote by ˆ η c ( x ) some estimator of conditional probability.
Analogously, g ( x ) := arg max c ˆ η c ( x ) and we can bound the excess risk in the following way:
[Equation]
where we used the fact that ˆ η g ∗ ( x ) ( x ) − ˆ η g ( x ) ( x ) ≤ 0 for any x .
The expectation of the right hand side in the case of kernel density estimator can be upper bounded by 2 (cid:113)
π τ ( x ) , where
[Equation]
and σ 2 c ( x ) =
η c ( x ) (cid:0) 1 − η c ( x ) (cid:1) .
Total uncertainty for multiclass problem is thus
[Equation]
B Architecture and Training Details for Image Datasets
Base Model.
For CIFAR-100 and ImageNet-like datasets, we are using ResNet50 as a base model, with or without spectral normalization [54].
For the spectral normalization, we use 3 iterations of the power method.
We use a ResNet50 architecture with implementation from PyTorch [62].
This architecture was implemented for the ImageNet dataset; thus, for the CIFAR-100, we had to adapt it.
We changed the first convolutional layer and used kernel size 3x3 with stride 1 and padding(instead of kernel size 7x7 with stride 2 and padding 3 used for ImageNet).
For CIFAR-100, we train the model for 200 epochs with an SGD optimizer, starting with a learning rate of 0.1 and decaying it 5 times on 60, 120, and 160 epoch.
For ImageNet, we train the model for 90 epochs with an SGD optimizer and learning rate decaying 10 times every 30 epochs.
For MNIST, we train a small convolutional neural network with three convolutional layers with padding of 1 and kernel size of 3.
Each of these layers is followed by a batch normalization layer.
Finally, it has a linear layer with Softmax activation.
This network achieves an accuracy of 0.99 on the holdout set.
We refer readers to our code for more specific details.
Ensemble.
For ensemble, we use a combination of 5 base models trained with different random seeds.
Test-Time Augmentation (TTA).
For TTA, we use a base model and apply different transformations on the inference stage.
Images of CIFAR-100 are randomly cropped with padding 4, randomly horizontally flipped, and randomly rotated up to 15 degrees.
ImageNet is randomly cropped from 256 to 224, randomly horizontally flipped, and the color was jittered (0.02).
Spectrally Normalized Models.
For SNGP, DDU and NUQ, we need spectral normalized models to extract features.
We wrapped each convolutional and linear layer with spectral normalization (PyTorch implementation).
We used 3 iterations of the power method in our experiments.
C Hyperparameters Selection Strategies
In this section, we collect all the hyperparameters one should choose to use NUQ, as well as we discuss strategies for choosing them.
C.1 Bandwidth
Probably the most important hyperparameter is bandwidth for kernels used in Nadaraya-Watson estimator.
It is extensively studied in literature (see, for example, [45, 68] and references therein).
However, there is still no silver bullet, and often the best approach for bandwidth selection is specific to a particular applied problem.
In this work we use cross-validation to estimate the accuracy of resulting Nadaraya-Watson based classifier, and tune the bandwidth to maximize it.
We implicitly use an assumption, that the bandwidth, which is good for in-distribution classification, will be still good for out-of-distribution detection.
Our experiments show, that this simple idea works well in practice.
C.2 Number of Nearest Neighbors
In this section, we demonstrate, how the number of nearest neighbors affects the results.
For the sake of demonstration, we have chosen the most challenging dataset (ImageNet) and its out-of-distribution counterparts.
It is important to note, that to make the experiment faster, we used only a subsample (75k) of the ImageNet dataset.
In Figure 5 we can see, that this hyperparameter has a wide interval, within which values do not affect the performance of the overall method.
Already starting from 20 nearest neighbours the results are close to the optimal ones (both in terms of accuracy and out-of-distribution ROC AUC).
This is due to the fact that typical kernels decay fast with distance, and there is no need to take a lot of nearest neighbors into account.
C.3 Marginal Density Estimation
To compute epistemic uncertainty according to equation (2), we need to estimate p ( x ) .
In general, there are multiple possible ways how one can do it (including Variational Autoencoders [34] and
Normalizing Flows [61]).
However, for computational efficiency something lightweight is required.
Specifically, we propose two ways.
The first one is to use another KDE with the same kernel and bandwidth used for NW estimator.
Another approach is to use training dataset embeddings and corresponding labels to assign a Gaussian distribution per class (GMM).
Note, that it is not a Gaussian
Mixture Model in the traditional sense, typically fitted with EM-algorithm.
From our experiments (see Table 5) we see, that both of them perform on par, with some advantages of GMM for CIFARdataset, while for ImageNet KDE works better.
C.4 Kernel for KDE
In principle, one could choose different kernels for both, KDE (see Table 5) and NW-regression.
But typically, as kernels decay fast with the distance, it does not affect much on the result.
Thus, Gaussian (RBF) kernel is a good default choice.
Below, we study the choice of a kernel to plug-in in our approach.
First, let us rewrite K h ( u ) as follows:
[Equation]
We consider the different choices of kernels, see Table 3.
[Figure]
A cc u r a c y /
R O
C
A U
C
Validation (InD) accuracy
[Figure] [Figure]
[Table]
D Consistency of NUQ-based Classification with the Reject Option
In this section, we derive a non-asymptotic upper bound of the excess risk used to obtain the consistency result in Section 4.
First, using results of the previous section, notice, that for an arbitrary rejection rule α ( x ) the excess risk of R λ ( x ) is at most
[Equation]
As previously,
[Equation]
Thus, asymptotically
[Equation]
Consequently,
[Equation]
That leads us to the procedure described as Algorithm 2.
Algorithm
Input: Samples ( X i , Y i ) , bandwidth h , parameters λ, β
Output: Accept or reject the regression result
Calculate ˆ p ( x ) , ˆ η c ( x ) for c ∈ C ; if the density estimation ˆ p ( x ) > 0 and the criterion holds:
[Equation]
then
Accept results of the regression else
Reject end
We formulate a number of mild assumptions:
Assumption D.1.
There exist Hessians of functions η c ( x ) , c ∈ C , and their spectral norms are bounded by some constant M η .
Assumption D.2.
L 2 -norms of ∇ p and ∇ 2 p are bounded by constants L d and M d respectively, i.e.
[Equation]
Assumption D.3.
There exist finite values
[Equation]
while
[Equation]
Under these assumptions, we state the following theorem:
Theorem D.4.
Suppose that assumptions D.1-D.3 hold, p ( x ) > 0 , and β < 1 / 2 .
Define ∆ = | λ − R ∗ ( x ) | .
Then, if λ < R ∗ ( x )
[Equation]
where
[Equation]
and
[Equation]
If R ∗ ( x ) ⩽ ∆ ,
[Equation]
Here ˜ q ∆ differs from q ∆ by replacing h 2 κ ∆ with h 2 κ ∆ + z 1 − β/ |C| ∥ K ∥ 2 (cid:113) 1 2 Nh 2 p ( x ) , while q
[Equation]
Notice, that Theorem 4.1 follows from Theorem D.4 as all the terms in the upper bound tend to zero when h → 0 and Nh d → ∞ with N → ∞ .
Proof of Theorem D.4.
For a reminder, the excess risk is
[Equation]
First, rewrite the expectation as an integral
E | ˆ
[Equation] [Equation]
[Equation]
dt
[Equation]
|
[Equation]
x
[Equation]
x
[Equation]
t and (cid:88)
i
[Equation]
X
[Equation]
x )
[Equation]
=(cid:33)
dt
[Equation]
and (cid:88)
i
[Equation]
dt
[Equation]
since we abstain if ˆ p ( x ) = 0 .
Due to Lemma D.5,
[Equation] [Equation]
and (cid:88)
[Equation]
Here we use the Poisson integral.
Denote this upper bound by R .
Now, assume λ <
R ∗ ( x ) .
Then the excess risk can be estimated in the following way:
[Equation]
x
[Equation]
x
[Equation] [Equation]

[Equation]
The event from the RHS implies that there is c ∈ C such that
[Equation]
and, consequently,
[Equation]
The upper bound was obtained using Lemma D.5.
Finally, consider the case R ∗ ( x ) ⩾ λ .
Then, we estimate
[Equation]
and
[Equation]
Similarly to Lemma D.
[Equation]
we bound the last probability by Bernstein’s inequality:
[Equation]
Lemma D.5.
Suppose all conditions of Theorem D.4 holds.
Then, for any non-negative r
P (ˆ η c ( x ) − η c ( x ) ⩾ r and (cid:88)
i
[Equation]
⩽ 1 { r ⩽ h
[Equation] [Equation]
exp
[Equation]
  and
P ( η c ( x ) − ˆ η c ( x ) ⩾ r and (cid:88)
[Equation]
⩽
[Equation]
{ r ⩽ h
[Equation]
} ∨
[Equation]

[Equation]

[Equation]
Proof.
Let us prove the first inequality, the second one can be proved in the same way.
Since ˆ p ( x ) > 0 , we can multiply both sides of the inequality ˆ η c ( x ) − η c ( x ) ⩾ r by (cid:80)
i K h
( X i − x ) .
Thus, the inner event implies (cid:88)
[Equation]
Define
[Equation]
In order to write a concentration we should analyze e .
Inequalities
[Equation]
which hold for each λ
[Equation]
x and y
[Equation]
guarantee us that the norm of the gradient ∇ η c ( x ) is bounded by
[Equation]
Moreover, non-negativity of p ( x ) , the L d -Lipschitz property and its L 1 -norm imply that p ( x ) is bounded by 2 L d d .
Then
[Equation]
Taylor’s expansion delivers the following:
[Equation]
Similarly,
[Equation]
Thus,
[Equation]
If e > 0 we estimate the probability by 1.
Otherwise
[Equation]
we utilize Bernstein’s inequality:
P (cid:32)(cid:88)
[Equation]
We estimate E K 2 h
( X i − x ) as follows:
[Equation]
D.1 Toy Example of Classification with Reject Option
For illustration
[Equation]
we present some experimental results with a toy example, see Figure 6.
We consider the smoothed step function as η ( x )
[Equation]
while data X i is distributed according to the normal distribution with the mean 0 . 5 and variance 0 .
04 (see Figure 10b).
We study the point-wise excess risk of NUQ and the plug-in rule.
For the points with high covariate mass (Figures 6c and 6d) methods show comparable results.
NUQ is useful for points lying with low covariate density, see Figure 6e.
However, for points without any label noise (Figure 6b) plug-in is still better as it quickly learns the correct class while NUQ is more conservative.
[Figure]
E Toy Experiment on Detecting Actual Aleatoric and Epistemic Uncertainties
In this section, we conduct a toy experiment, for which we explicitly know what should be the true probability of class one, as well as the true data density.
Let us consider a binary classification problem.
Our dataset consists of 5000 samples from three different one-dimensional Gaussians, located to mix classes.
Colors denote class label: red – 0; green – 1, see Figure 7a.
For this particular data model, we can compute the conditional probability of a data point x belongs to class 1: η ( x ) =
p ( Y = 1 | X = x ) .
We build an estimate of this conditional using our Nadaraya-Watson kernel-based approach ˆ η ( x ) .
Further, we generate a uniform grid, and for each point of this grid, using our method, we can upper bound difference between the true conditional and our approximation.
This difference, according to our approach, is considered as an epistemic uncertainty (see Figure 7b).
The green line in this plot denotes an absolute difference between the true conditional and our approximation.
The red line denotes our epistemic uncertainty.
From the picture, we can see that our epistemic uncertainty approximates the probabilities difference well.
Next, we show how our aleatoric uncertainty relates to the true class 1 conditional probability.
In the Figure 7c we show true conditional distribution η ( x ) (orange line) and our approximation of the aleatoric uncertainty min { ˆ η ( x ) , 1 − ˆ η ( x ) } (red line).
We can see that our approximation is high exactly in the same regions where the true conditional is absolutely unsure about the class label.
[Figure]
true conditional probability.
F Additional Experiments on Image Datasets F.1 Rotated MNIST
The first example is classification under covariate shift on MNIST [40].
We train a small convolutional neural network with three convolution layers, see Section B. This is the base model we use to obtain logits for the input objects.
We consider a particular instance of distribution shift for evaluation by using a test set of MNIST images rotated at a random angle in the range from 30 to 45 degrees.
This set contains 10000 images.
The range of angles reassures that the data does not look like the original
MNIST data, though many resulting pictures can still remind the ones from training.
This experiment considers two simple baselines: MaxProb and Entropy-based uncertainty estimates of the base model.
We compliment them with two more challenging baselines:
Deep ensemble and DDU [55] (as the most successful among deterministic methods).
We compare them all with
NUQ-based estimate of epistemic uncertainty ˆ U e ( x ) .
To evaluate the quality of the uncertainty estimates, we sort the objects from the test dataset in order of ascending uncertainties.
Then we obtain the model’s predictions and plot how accuracy changes with the number of objects taken into consideration; see Figure 8a.
The valid uncertainty estimation method is expected to produce the plot with accuracy decreasing when more objects are taken into account.
Moreover, the higher is the plot, the better is the quality of the corresponding uncertainty estimate.
We see that the plots for all the considered methods show the expected trend, while uncertainties obtained by NUQ are more reliable.
NUQ distinctly outperforms DDU and has comparable performance with deep ensembles.
F.2 MNIST vs. SVHN
To make the problem more challenging, we consider the SVHN dataset [58], convert it to grayscale, and resize it to the shape of 28x28.
The size of this additional SVHN-based dataset is again 10000.
[Figure] [Figure]
SVHN and for ImageNet it is
ImageNet-R.
We take the base model trained on MNIST from the previous section and consider the problem of
OOD detection with SVHN being the OOD dataset.
As in-distribution data, we first consider the test set of 10000 MNIST images.
We again compute uncertainties for each object on this concatenated dataset (10000 of MNIST and 10000 of SVHN) and sort them by their uncertainties in ascending order.
The goal for uncertainty quantification methods is to sort all objects so that all MNIST images have lower uncertainty values than SVHN ones.
Note that the optimal decision rule in this case is a
ReLU-shaped function, with a break at point 10000.
For NUQ we use epistemic uncertainty ˆ U e ( x ) in this experiment.
In Figure 8b we plot the number of objects included from the SVHN dataset.
It is seen that Ensembles, NUQ, and DDU outperform
MaxProb and Entropy.
All of these three methods perform almost as an optimal decision.
Next, we consider more challenging problem of separation between rotated MNIST (see Section F.1) and SVHN.
We expect it is harder to distinguish between them as rotated MNIST images differ from those used to train the network.
However, Figure 8c shows that NUQ still does a very good job and allows for almost perfect separation.
Interestingly, this example shows that ensembles are worse than
DDU and NUQ.
The performance of the last two is visually almost identical.
F.3 Performance Difference on CIFAR-100 and ImageNet
One of the things that caught our attention is the superior performance of NUQ on ImageNet, given that it has very similar results with DDU on CIFAR-100.
One of our hypotheses was that embeddings have a more complex and multi-modal distribution for a more complex ImageNet dataset compared to simpler CIFAR-100.
To check this, we made t-SNE based embeddings of out-of-distribution and test data (see Figure 9).
While we understand the limitation of this type of visualization, the ImageNet embeddings appear to be much more irregular compared to well-shaped clusters for CIFAR-100.
Because of that, the modeling of the class with a single Gaussian (in DDU) might not work very well for ImageNet.
NUQ approach performs the modeling of distributions in a much more flexible way, which is beneficial for approximating complex distributions.
We hypothesize that this is the reason for the NUQ’s superior performance.
F.4 Ablation Study on CIFAR-
We need an estimator of marginal density p ( x ) for our method, and there exist different options.
We consider kernel method with RBF kernel and logistic kernel and Gaussian mixtures model (GMM).
There is also a question about which embeddings to use – the DDU paper [55] proposes to take the features from the second last layer; while logits from the last layer represent a reasonable choice as well.
To validate the options, we conducted some ablation study on out-of-distribution detection for the CIFAR-100 dataset, similar to the main experiment.
First, we compare the DDU and NUQ on embeddings from the second last and last layers (Table 4) on SVHN, LSUN, and Smooth datasets.
Secondly, we compare the NUQ method on RBF, logistic kernel, and GMM for both last and penultimate layer embeddings (Table 5).
As we can see from the tables, the optimal option is GMM density on the penultimate layer.
[Table] [Table]
[Table] [Table]
Kernel-based methods rely on the “reasonable” geometry of the embedding
, meaning that embeddings of similar images should be not too far and different images should not collapse into a single point.
Our motivation to use spectral normalization during training is to make the embedding space smooth with respect to input images.
We have conducted an extra ablation study, comparing the result for feature extractors with and without spectral normalization, see Table 6.
The results confirm our hypothesis, as the spectral-normalized version performs better, though the NUQ beats the baseline even without applying the modification to the ResNet training.
We also show here that entropy performs better than maximum probability as an uncertainty measure.
F.5 Sensitivity to Ensemble Size
In this section, we explore the ensemble model performance regarding the number of models.
From
Table 7, we can see that 5 models is a reasonable amount number for CIFAR-100.
For the ImageNet dataset (Table 8), increasing the number of models gives a steady gain, but still 5 models provide the gain within the error margin.
[Table] [Table]
The number of models above 5 give almost no gain (even some loss sometimes) within an error margin.
[Table]
F.6 Additional Experiments with DUQ
DUQ [69] is one of the baselines in the paper.
We chose it as similarly to our method it requires only a single forward pass and uses post-processing for embeddings.
In the original article, the method shows a good result on a relatively small dataset CIFAR-10 with a ResNet18 model.
We tried to train it on CIFAR-100 and ImageNet with a larger model, ResNet50, but there were difficulties with training process as method failed to converge to the model of reasonable quality.
We believe the cause of the problem was gradient penalty as a regularization method, and we switched to spectral normalization instead.
DUQ training requires a balance between hyperparameters such as length scale, momentum, and learning rate, so we initially trained the model with a pre-trained feature extractor.
With careful selection of parameters, we managed to train end-to-end as well
[Table]
and we observed improvement in all experiments (see Tables 9 and 10), although methods like DDU and
NUQ had more stable training in our experience and a better final result
[Table] [Table]
F.7 Computational Costs
We benchmarked the training and inference time overhead for our ImageNet experiments.
Base model training time corresponds to training of a ResNet-50 feature extractor on a corresponding dataset.
The NUQ training time is measured on a full training dataset and includes the parameter search time.
The inference time is measured on a full test dataset.
Results are presented in Table 11, where we can see that training overhead is less than 1% and inference overhead is less than 10%, while for ensembles, the overhead would be n-fold.
[Table]
[Table]
F.8 Choice of Uncertainty Measure for Ensembles
In the case of ensembles
[Table]
we have multiple predictions for a single point.
It also applies to other methods like test-time augmentation and Monte-Carlo dropout.
To get a single value of uncertainty
[Table]
we must choose the particular uncertainty measure based on .
We have tried a few options.
Namely, we used mean maximum probability, a standard deviation of predicted probabilities between different runs, mutual information
[Table]
and entropy.
However, in the manuscript
[Table]
we decided to focus on only one approach (entropy) to reduce clutter
[Table]
while in our experiments, it performed better on average.
We present the results for test time augmentation and ensembles on ImageNet here, see Table
[Table]
F.9 Detecting OOD Images for ImageNet
By analogy with Section F.
[Table]
we conducted experiments with vanilla ImageNet images vs ImageNet-R and ImageNet
-O.
The idea is to mix images from two datasets and then sort them by uncertainty.
For normal images uncertainty tends to be lower, so we can illustratively see the methods performance (Figure 10).
In case of ImageNet-O, basic models like max probability and ensemble have difficulties, while NUQ and DDU performed reasonably well.
For ImageNet-R, NUQ has performance close to optimal
[Figure]
G Hyperparameter Values and Dataset Statistics for Experiments on Textual Data
For the optimal hyperparameter search in the experiments on textual datasets, we use Bayesian optimization with an early stopping algorithm.
We divide the original training data into validation and training subsets in a ratio of 20 to 80 and perform optimization using sets of pre-defined values for each hyperparameter, which are given in the caption of Table 13.
As an objective metric, we use the accuracy score.
The dataset statistics are presented in Table
[Table]
Optimal hyperparameters for the experiments with ELECTRA on textual data.
“Objective score” refers to the accuracy score for classification on the validation sample.
We select hyperparameter values from the following pre-defined list:
Learning rate : [5e-6, 6e-6, 7e-6, 9e-6, 1e-5, 2e-5, 3e-5, 5e-5, 7e-5, 1e-4];
Num. of epochs : { n ∈ N | 2 ≤ n ≤ 15 } ; Batch size : [4, 8, 16, 32, 64]
[Table]
Weight decay : [0, 1e-2, 1e-1].
[Table]