Nonparametric Uncertainty Quantiﬁcation for Single Deterministic Neural Network
Abstract
This paper proposes a fast and scalable method for uncertainty quantiﬁcation of machine learning models’ predictions.
First, we show the principled way to measure the uncertainty of predictions for a classiﬁer 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 classiﬁcation 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 reﬂect 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 reﬂects 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 ﬁelds, such as medicine [53], autonomous driving [43, 20], and ﬁnance [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 overconﬁdent 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 Correspondence to: < Nikita. Kotelevskii
> < Maxim. .ae 36th Conference
Systems reliable uncertainty estimates (UEs) 1 .
However, along with that, they introduce large computational overhead and might require big modiﬁcations 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 efﬁcient 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 Quantiﬁcation (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 conﬁdent 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 quantiﬁcation (see Section 2), which is (a) applicable to any deterministic neural network model, (b) has an efﬁcient implementation, (c) allows to disentangle aleatoric and epistemic uncertainty, (d) outperforms other techniques on image and text classiﬁcation tasks (see Section 6).
We formally prove the consistency of the NUQ-based estimator when applied to the problem of classiﬁcation with the reject option, see Section 4. 3.
We conduct a vast empirical investigation of NUQ and other UE techniques on image and text classiﬁcation tasks that supports our claims, see Section 6.
Nonparametric Uncertainty Quantiﬁcation 2.1 Classiﬁcation 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 classiﬁcation setup ( X, Y ) 2 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 =  ( 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 ﬁnd a rule ˆ g , which approximates the optimal one:
[Equation] Here, g : R d ! { 0 , 1 } is any classiﬁer, and the probability of wrong classiﬁcation P ( g ( X ) 6 = Y ) is usually called risk .
The rule g ⇤ is given by the Bayes optimal classiﬁer :
[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 6 = 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 ) 6 = 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 ) 6 = p train ( X ) is known as covariate shift .
The rule g ⇤ is still valid, i.e., optimal under P test .
However, while the classiﬁer 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 classiﬁcation rule ˆ g ( X ) =
ˆ g D ( X ) constructed based on the dataset D .
Let us start from deﬁning the pointwise risk of a prediction:
[Equation]
where P (ˆ g ( X ) 6 = Y | X = x ) ⌘ P train (ˆ g ( X ) 6 = Y | X = x ) ⌘ P test (ˆ g ( X ) 6 = Y | X = x ) under the assumptions above.
The value
R ( x ) is independent of the covariate distribution p test ( X ) and essentially allows to deﬁne 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 ﬁrst assume that the classiﬁer ˆ 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 classiﬁcation.
While this upper bound still depends on the unknown quantity ⌘ ( x ) , we will see in the next section that L ( x ) allows for an efﬁcient approximation under mild assumptions.
2.3 Nonparametric Uncertainty Quantiﬁcation 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 7! 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 classiﬁcation,  2 ( x ) = ⌘ ( x )  [Equation]  .
The constant ˜ C =
R [ 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 ﬁrst 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 quantiﬁcation procedure inspired by the derivation above, which we call Nonparametric Uncertainty Quantiﬁcation (NUQ) .
More speciﬁcally, 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 ( ⇠ ) q 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 ﬁnite 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.
Efﬁcient 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: k x  x i k .
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 ﬁnding 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 ﬁt 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 ﬂexible 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 classiﬁer based on conditional label probabilities estimated in a non-parametric way:
[Equation]
The bandwidth h is tuned via cross-validation optimizing the classiﬁcation accuracy on the training data (see SM, Section C.1).
Input: Training set { ( x i , y i ) } Ni =1 , inference point x , bandwidth h
Output: Prediction ˆ g ( x ) and uncertainty estimate ˆ U t ( x ) { x i k } Kk =
K nearest neighbors of x among { x i } Ni = ˆ p ( Y = c | X = x )
P Kk =1 K h ( x ik  x ) [ y ik = c ] P Kk =1 K h ( x ik  x ) ˆ c
[Equation] x ) = [Equation] p
[Equation]
Y [Equation] )  [Equation]
)  ˆ [Equation] ( x ) argmax c ˆ p ( Y = c
| X = x ) ˆ p ( x ) either KDE: 1 Nh d P Kk =1 K h ( x i k  x ) or GMM ˆ ⌧ 2 ( x ) 1 N max c ˆ  2 c ( x ) ˆ p ( x ) ˜ C, where ˜ C = R [ K h ( u )]
2 d u ˆ U t
( x ) min c  1  ˆ p ( Y = c | X = x ) +q 2 ⇡ ˆ ⌧ ( x )
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 beneﬁts of these approaches in Section F.4.
Consistency of NUQ-based Classiﬁcation 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 classiﬁcation 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  2 (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 classiﬁer g ⇤ ( x ) and the abstention function
[Equation]
To approximate ↵ ⇤ ( x ) , we utilize hypothesis testing:
[Equation]
We choose the conﬁdence level  > 0 and consider the statistic ˆ U  ( x ) = min
[Equation] 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  ˆ ⌘ ( x ) , 1  ˆ ⌘ ( x ) and the term z 1   ˆ ⌧ ( x ) accounting for the conﬁdence of estimation.
The resulting abstention rule is given by:
[Equation]
Finally, if we consider the pair of kernel classiﬁer ˆ 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 ! 1 as N tends to inﬁnity.
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 ﬁnite sample bounds provided in SM, Section D. We also experimentally illustrate the beneﬁts 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 quantiﬁcation.
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 quantiﬁcation 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 conﬁdence measure.
SNGP [46] and DUE [70] are similar but use a Gaussian process as the ﬁnal layer, requiring estimating covariance with the use of inducing points or RFF expansion.
There is a wide range of papers discussing classiﬁcation with the reject option.
Most likely, the problem was ﬁrstly 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 classiﬁcation datasets.
In each experiment, (1) we train a parametric model – a neural network, which we call a base model ; (2) ﬁt 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 sufﬁciently 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 classiﬁcation 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.
Speciﬁcally, we compute the agreement between predictions obtained from the Bayes classiﬁer based on kernel estimate (i.e. the one used in NUQ) and base models’ predictions.
This metric formally can be deﬁned as agreement (ˆ p, p
[Equation]
⇤ . 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 are shown
[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 Classiﬁcation
The main experiments with image classiﬁcation are conducted on CIFAR-100 [36] and ImageNet [12].
However, several additional experiments with other image classiﬁcation 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 signiﬁcant modiﬁcations to model architectures and training procedures.
More speciﬁcally, 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 ﬁrst 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 ﬁxed 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 classiﬁcation (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 signiﬁcant 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 beneﬁcial 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 signiﬁcantly 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 beneﬁcial in this case as KDE is much more ﬂexible 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 Classiﬁcation
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 classiﬁcation:
DDU and deep ensemble, and to the standard baselines: MC dropout and MaxProb.
The methods are evaluated on two tasks: OOD detection and classiﬁcation with a reject option.
Classiﬁcation 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 ﬁnal score is averaged across all OOD datasets.
Evaluation metric is ROC-AUC as in the image classiﬁcation 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 classiﬁcation layer.
The details of the model, hyperparameter optimization, and UE methods are presented in SM, Section G.
6.3.1 Classiﬁcation with a Reject Option
Figure 3 presents the results for classiﬁcation 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 efﬁcient methods and has similar performance as computationally expensive MC dropout.
[Figure] [Figure]
On SST-2, NUQ 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 classiﬁcation 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 conﬁdently 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 signiﬁcantly 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 signiﬁcant margin.
NUQ is also superior to DDU and other methods on text classiﬁcation datasets in both OOD detection and classiﬁcation 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 quantiﬁcation 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 justiﬁcation 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 reﬂect 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 speciﬁc 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 identiﬁable 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?
[-The expectation of the right hand side in the case of kernel density estimator can be upper bounded by 2 (cid:113) 
-]
[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]