Calibration of Neural Networks using Splines
Authors: Kartik Gupta
Amir Rahimi
Thalaiyasingam Ajanthan
Thomas Mensink
Cristian Sminchisescu
Richard Hartley
Venue: ICLR 2021 Poster (2021)
Keywords: neural network calibration
uncertainty
calibration measure

Abstract: Calibrating neural networks is of utmost importance when employing them in safety-critical applications where the downstream decision making depends on the predicted probabilities. Measuring calibration error amounts to comparing two empirical distributions. In this work, we introduce a binning-free calibration measure inspired by the classical Kolmogorov-Smirnov (KS) statistical test in which the main idea is to compare the respective cumulative probability distributions. From this, by approximating the empirical cumulative distribution using a differentiable function via splines, we obtain a recalibration function, which maps the network outputs to actual (calibrated) class assignment probabilities. The spline-fitting is performed using a held-out calibration set and the obtained recalibration function is evaluated on an unseen test set. We tested our method against existing calibration approaches on various image classification datasets and our spline-based recalibration approach consistently outperforms existing methods on KS error as well as other commonly used calibration measures. Code is available online at https://github.com/kartikgupta-at-anu/spline-calibration.

Published as a conference paper at ICLR 2021
CALIBRATION OF NEURAL NETWORKS USING SPLINES
Kartik Gupta Amir Rahimi', Thalaiyasingam Ajanthan', Thomas Mensink Cristian Sminchisescu', Richard Hartley
Thomaa
'Australian National University, 1Dtta61, CSIRO, 'Google Research
(kartik. gupta, amir rahimi, thwlaahasinnnaaae a janthan] Banu. eduu.uedd.com (mensink, sminchisescu, wwweeeessuiicrrcaahaaahaaaaaeeee ott.s//s..p.ccccccccaorreeeooooe com
ABSTRACT
Calibrating neural networks is of utmost importance when employing them in safety-critical applications where the downstream decision making depends on the predicted probabilities. Measuring calibration error amounts comparing two em- pirical distributions, In this work, we introduce binning-free calibration measure inspired by the classical Kolmogorov-Smirno (KS) statistical test in which the main idea is to compare the respective cumulative probability distributions. From this, by approximating the empirical cumulative distribution using a differentiable function via splines, we obtain recalibration function, which maps the network outputs to actual (calibrated) class assignment probabilities. The spline-fitting is performed using a held-out calibration set and the obtained recalibration function is evaluated on an unseen test set. We tested our method against cxisting calibration approaches various image classification datasets and our spline-based recalibra- tion approach consistently outperforms existing methods on KS error as well as other commonly used calibration measures.
INTRODUCTION
Despite the success of modern neural networks they are shown to be poorly calibrated (Guo et al. (2017)) which has led to growing interest in the calibration of neural networks over the past few years (uull et al. (2019) Kumar et al. (2019; 2018); Müller et al. (2019).. Considering classification problems, classifier is said to be calibrated if the probability values it associates with the class labels match the true probabilities of correct class assignments. For instance, if an image classifier outputs 0.2 probability for the "horse" label for 100 test images, then out of those 100 images approximately 20 images should be classified as horse. It is important to ensure calibration when using classifiers for safety-critical applications such as medical image analysis and autonomous driving where the downstream decision making depends on the predicted probabilities.
One of the important aspects of machine learning research the measure used to evaluate the perfor- mance of model and in the context of calibration, this amounts to measuring the difference between two empirical probability distributions. To this end, the popular metric, Expected Calibration Error (ECE) Nacini et al. (2015)), approximates the classwise probability distributions using histograms and takes an expected difference. This histogram approximation has a weakness that the resulting calibration error depends the binning scheme (number of bins and bin divisions). Even though the drawbacks of ECE have been pointed out and some improvements have been proposed (Kumar et al.) (2019); Nixon al. ). the histogram approximation has not been eliminated!!
In this paper, we first introduce a simple, binning-free calibration measure inspired by the classical Kolmogorov-Smirrov (KS) statistical test (Kolmogorov (133), [Smirnov] 1939)). ). which also provides an effective visualization of the degree of miscalibration similar to the reliability diagram (Niculescu Mizil & Caruanal (2005).. To this end, the main idea of the KS-test is compare the respective classwise cumulative (empirical) distributions. Furthermore, by approximating the empirical cu- mulative distribution using differentiable function via splines (McKinley & Levine (1998)), we
We consider metrics that measure classwise (top-r) calibration emorr for details.
Kull et al. 2019) ). Refer to section

---

Published as a conference paper at ICLR 2021
obtain analytical recalibration functior which maps the given network outputs to the actual class assignment probabilities. Such a direct mapping was previously unavailable and the problem has been approached indirectly via learning. for example. by optimizing the (modified) cross-entropy loss (Guo) et al. 2017;; Mukhoti et al. (2000); Müller et al. (2019). Similar to the existing methods (Guo et al. (2017) Kull et al. 20T9g) the spline-fitting is performed using held-out calibration set and the obtained recalibration function is evaluated on an unseen test set.
We evaluated our method against existing calibration approaches on various image classification datasets and our spline-based based recalibration approach consistently outperforms existing methods on KS error, ECE as well as other commonly used calibration measures. Our approach to calibration does not update the model parameters, which allows it to be applied on any trained network and it retains the original classification accuracy in all the tested cases.
NOTATION AND PRELIMINARIES
We abstract the network as function fo D - [0, 1]K where 'D C IR and write fo(x) Here, x may be an image, or other input datum, and is a vector, sometimes known as the vector of logits. In this paper, the parameters 0 will not be considered, and we write simply f to represent the network function. We often refer to this function as a classifier, and in theory this could of some other type than neural network.
In a classification problem. K is the number of classes to be distinguished, and we call the value 2g (the k-th component of vector z) the score for the class k. If the final layer of network is softmax layer, then the values 2µ satisfy _km1 ² 1, and 2 2 O. Hence, the zμ are pseudo- probabilities, though they do not necessarily have anything to do with real probabilities of correct class assignments. Typically, the value y" arg max; 2i: is taken the (top-1) prediction of the network, and the corresponding score, max; 2). is called the confidence of the prediction. However, the term confidence does not have any mathematical meaning in this context and we deprecate its use.
We assume we are given set of training data (x., where E D is an input data element, which for simplicity we call an image, and y: K = (1....,k) is the so-called ground ttrth label. Our method also uses two other sets of data, called calibration data and test data.
would be desirable if the numbers z output by a network represented true probabilities. For this to make sense, we posit the existence of joint random variables (X, (X.Y). where X takes values in a domain D c. IR, and Y takes values in K. Further, let Z = f(X). another random variable, and Z fa (X) be its k-th component. Note that in this formulation X and Y are joint random variables, and the probability P(Y X) is not assumed to be 1 for single class, and 0 for the others.
A network is said to be calibrated if for every class k,
P(Y = k Z = 2) 2k
(1)
This can be written briefly as P(k] f(x) = fx(x)) 24. Thus, if the network takes input x and outputs fx),, then z represents the probability (given f()) that image x belongs to class k.
The probability P(k 12) difficult to evaluate, even empirically, and most metries (such as ECE) use or measure a different notion called classwise calibration (Kull et al. (2019): Zadrozny & Elkan 22022), defined as,
P(Y k Zx = 2x.
2k
This paper uses this definition 2 of calibration the proposed KS metric.
Calibration and accuracy of a network are different concepts. For instance, one may consider classifier that simply outputs the class probabilities for the data, ignoring the input x. Thus,
fx(x) 2 P(Y k). this classifier is calibrated but the accuracy is no better than the random predictor. Therefore, in calibration of a classifier, it is important that this is not done while sacrificing classification (for instance top-1) accuracy.
Open-source implementation available at https://githuue http:///ittuu..oo/kttttttt www. kgupta anu sp1 ne- cal libration
2

---

Published as a conference paper at ICLR 2021
The top-7 prediction. The classifier f being calibrated means that fx(x) is calibrated for each class k. not only for the top class. This means that scores 2g for all classes & give a meaningful estimate of the probability of the sample belonging to class k. This is particularly important in medical diagnosis where one may wish to have a reliable estimate of the probability certain unlikely diagnoses.
is most interested in the probability of the top scoring class, the top-1 prediction, or in general the top-r prediction. Suppose a classifier f is given with values in [0, 1] and let y be the ground truth label. Let us use / to denote the r-th top score (so ((-1) would denote the top score; the notation follows python semantics in which A[-1] represents the last element in
Frequently, however,
array A). Similarly we define max(-r) for the r-th largest value. Let f(-r) D - [0, 1] be defined
as
(x- = max (nax(-))a (rr fx(x), and y y1-)
= {
if y arg max (-r) fx(() otherwise
(3)
In words, y(-r) is if the r-th top predicted class the correct (ground-truth) choice. The network calibrated for the top-r predictor if for all scores 0,
((y f (xx σ) =
In words, the conditional probability that the top-r-th choice of the network is the correct choice, is equal to the r-th top score.
Similarly, one may consider probabilities that datum belongs of the top-r scoring classes. The classifier is calibrated for being within-the-tope classes if
P( = E = o) a
(5)
Here, the sum on the left is 1 if the ground-truth label is among the top r choices, 0 otherwise, and the sum on the right is the sum of the top r scores.
SLAMOGOROV-SMIRNEE CALIBRATION ERROR
now consider a way to measure a classifier is classwise calibrated, including top-r and within- top-r calibration. This test is closely related to the Kolmogorov-Sminn -miinov test (Kolmogorov (1933); Smirnoy| (1939h) for the equality of two probability distributions. This may be applied when the probability distributions are represented by samples.
We start with the definition classwise calibration:
P(Y 1 [x(X) = 2x) = 2k
(6)
P(Y k fa(X) zx) =x (X) =x),,
Bayes' rule
This may be written more simply but with a less precise notation as
P(zu, k) 2 P(zx).
Motivation of the KS test. One is motivated to test the equality (or difference between) two distributions, defined on the interval [0, 1J. However, instead of having a functional form of these distributions, one has only samples from them. Given samples (x,, yi), it is not straight-forwant to estimate P(zx) or P(zz ke), since given value 2 is likely to occur only once, not at all, since the sample set is finite. One possibility is to use histograms of these distributions. However, this requires selection of the bin size and the division between bins, and the result depends these parameters. For this reason, we believe this is an inadequate solution.
The approach suggested by the Halmogorov--mimmon test is to compare the cumulative distributions. Thus, with & given, one tests the equality
[e P(zx, k) dzy 10 2x P(zx) dzc
Writing Φi (a) and (2 to be the two sides of this equation, the KS-distance between these two distributions defined as KS max, 10 (a) (z)).. The fact that simply the maximum is used
3

---

Published as a conference paper at ICLR 2021
here may suggest lack of robustness, but this is maximum difference between two integrals, reflects an accumulated difference between the two distributions.
To provide more insights into the KS-distance, let consider or enttaatss P[k] zx) (which is usually the case, at least for top-1 classification (uuo et al. (2017)), then P(k] z - 2j has constant sign for all values of 2₁- It follows that P(*k, k)) 2 P(zs) has constant sign and so the maximum value in the KS-distance is achieved when o = 1. In this case,
where 2ą consistently
KS J. |P(EL, zn P(xx) dzz =
=S. |P(k [x) zz. P(=x) dz
which is the expected difference between and P(k: =1)) This can be equivalently referred to as the expected calibration error for the class k.
Sampled distributions. tive distributions by
Given samples (x,, V) and fixed k, one can estimate these cumula-
[ k(z dzz ~
Σ 1=1
x k)
N
where 1 B -> (0. 1) is the function that returns if the Boolean expression is true and otherwise 0. Thus, the sum simply count of the number of samples for which y/: and fx(x;) S a, and so the integral represents the proportion of the data satisfying this condition. Similarly.
1xxx zu: P(zx) day
1 (()((x)) (x.) N
Σ
(10)
These sums can be computed quickly by sorting the data according the values fx (x:), then defining two sequences as follows.
ho ho 0,
h; = h4-1 1 = kk/N
(11)
h: h4-1 + fu(x:)/N.
The two sequences should be the same, and the metric
KS(fe) max 1h, hz]
(12)
gives numerical estimate of the similarity, and hence measure of the degree of calibration of fu- This is essentially a version of the Kolmogorov-Smiroo test for equality of two distributions.
Remark. All this discussion holds also when k: < O, for top-r and within-top-r predictions as discussed in section 2 In (11), for instance, f-1 (x;) means the top score, f-1(x,) = max maxx(f (xx(x))). or more generally, (x.) means the r-th top score. Similarly, the expression yı -r means that y:
is the class that has the r-th top score. Note when calibrating the top-1 score, our method is applied after identifying the top-1 score, hence, it does not alter the classification accuracy.
4 RECALIBRATION USING SPLINES
The function h; defined in II computes an empirical approximation
h4 P(Y k, fa S fx(x;))
(13)
For convenience, the value of fa will be referred the score. We now define continuous function I(()) for / E [0.1] by
h(1) P(Y k, (x) s()))
(14)
where s(t) is the t-th fractile score, namely the value that proportion t of the scores fx(X) lie below. For instance s0..5) is the median score. So, h, an empirical approximation to h(t) where t = i/N. We now provide the basic observation that allows compute probabilities given the scores.
4

---

Published as a conference paper at ICLR 2021
Test Classt I] Uncalibrated
KS 5490%, P2obobilit--2--00
Cuauubstve Score Probobiii
0.-
Scote: Proosbhiiio
0.5
02-
Scrre
Probaddyy
Percentlc
Custalativee Stote
Percenille
Score
(8)
(b)
(6)
(4)
Figure 1: Calibration graphs for an uncalibrated DenseNet-40 (Huagg et al. (2017)) trained on CIFAR-IO for top-1 class with a KS error of 5.5%, and top-1 accuracy of 92.4% of cumulative score and probability versus the fractile of the test set, (b) shows the same information with the horizontal axis warped so that the cumulative-scuv score graph is straight line. This is created as scatter plots of cumulative (score, score): blue and (score, probubility): orange. If the network is perfectly calibrated, the probability line will be straight line coincident with the (score, score) line. This shows that the network substantially overestimating (score) the probability of the computation. (c) and (d) show plots of [non-cumulative) score and probability plotted against fractile, or score. How these plots are produced is described in section 4
test set. Here (a) shows the plot
Proposition 4.1. ((t) = P(Y = k. fx())= I s(t)) as in 14) where s(t) is the 1-th 1-th fractile score, then (t) P(Y fx( = s(t)), where h (t) dh/ dh.dt.
Proof. The proof relies on the equality P(fa (X) S s(t) = t. words, since s(t) is the value that fraction t of the scores are less than or equal, the probability that score is less than or equal to s(t), (obviously) equal to f. See the supplementary material for detailed proof.
Notice N' (t) allows direct conversion from score to probability. Therefore, our idea to approximate h; using differentiable function and take the derivative which would be our recalibration function.
4.1 SPLINE FITTING
The function h, (shown in fig [a) is obtained through sampling only. Nevertheless, the sampled graph is smooth and increasing. There are various ways to fit a smooth curve to it, so as to take derivatives. We choose fit the sampled points h, to cubic spline and take its derivative.
Given sample points (u., x)) in IR x IR, easily available references show how to fit smooth spline curve that passes directly through the points (u,, vz). A very clear description is given in McKKnney & Levine ( (1998), for the case where the points u; are equally spaced. We wish, however, to fit a spline curve with small number of knot points to do least-squares fit to the points. For convenience, this is briefly described here.
cubic spline u(u) is defined by its values at certain knot points (út, 0z 0z) In fact, the value of the curve at any point u can be written as a linear function vuu) = Ek=n ax(u),z = a aT(u) v, where the coefficients dg depend on w u Therefore, given a set of further points (u,, x) which may be different from the knot points, and typically more in number, least-squares spline fitting of the points (u,, vx) can be written as least-squares problem minę |A(u) - v/l², which is solved by standard linear least least-squares techniques. Here, the matrix has dimension N K with N > K. Once is found, the value of the spline at any further points u is equal to v(u) auu) V. a linear combination of the knot-point values ūz.
Since the function is piecewise cubic, with continuous second derivatives, the first derivative of the spline is computed analytically. Furthermore, the derivative v' (u) can also be written as a linear combination o' (') a' a'(u) (u)T v. where the coefficients a' (u) can be written explicitly.
Our goal is to a spline to set of data points (u, v4) = (i/N, h.) defined in [ other words,
the values h; plotted against fractile score. Then according to Proposition 4.1 the derivative of
the spline is equal to P(k (X) = s(t)). This allows a direct computation of the conditional probability that the sample belongs to class k.
Here and elsewhere, notation such and denotes the vector of values U; ag. as appropriate.
5

---

Published as a conference paper at ICLR 2021
Calls Class Calihmtedd
Probabilit
Cuuuubitve Score Probbbllyy
Scote Froschitty
54-
05-
Scn
Proabday
Percesile
Cunralative Stote
Percenille (0)
Score (4)
(6)
(b)
Test Classi-1 []] Calibrated
KS-emor 0.166% Probability
Canalitiv Scnr
Coemlabe
Scon Prcbliiity
Canuaatvv Squre Proddciiity
Canalitiv hulabilyy
Cuexlato Prihultty
Score: PPobbbhiitt
0.4
State
Probabibyy
10
18
8.5 Cumaabliive Scote
04
Perozntic
Percentlle
Same
(20
The result of the spline calibration method, the example given in fig for top-1 calibration, recalibration function IR + IR is used to adjust the scores, replacing fx(x) with ((J(x)) (see section 4.2). As is seen, the network now almost perfectly calibrated when tested on the "calibration" set (top row) used to calibrate it. In bottom row, the recalibration function is tested on further set "test". ; It is seen that the result is not perfect, but much better than the one in fig Tt. It is also notable that the improvement in calibration is achieved without any loss of accuracy.
Figure 2:
Since the derivative of h; is probability, one might constrain the derivative to be in the range [o, 1] while fitting splines. This can be easily incorporated because the derivative of the spline is linear expression in ú; The spline fitting problem thereby becomes a linearly-constrained quadratic program (QP). However, although we tested this, in all the reported experiments, simple least-squares solver is used without the constraints.
4.2 RECALIBRATION
We suppose that the classifier f = fo fixed, through training the training set. Typically, if the classifier is tested on the training set, it is very close to being calibrated. However, if a classifier f' is then tested different set of data, it may be substantially mis-calibrated. See fig
Our method of calibration is to find a further mapping [0, 1 - [o. 1), such that o fa is calibrated.
This is easily obtained from the direct mapping from score fa (x) to P(k: (x)) (refer fig It. I) In
equations, 7(0) = h'(s (a)). and taking its derivative. The function - is a mapping from the given score o to its fractile s (a).
(a)). The function h is known analytically, from fitting spline to l((t)
Note that, held out calibration set is used to fit the splines and the obtained recalibration function evaluated on an unseen test set.
To this end, given sample from the test set with (x) a., one can compute (s ((s--(a) directly in one step by interpolating its value between the values of hf(f((x)) and (f(x(xx--)) where x; and X;+1 are two samples from the calibration set, with closest scores on either side of a. Assuming the samples the calibration set are ordered, the samples x; and x;+1 can be quickly located using binary search. Given a reasonable number of samples in the calibration set, (usually in the order of thousands), this can be very accurate. In our experiments, improvement calibration observed in the test set with difference to the accuracy of the network (refer to fig 2H). fitting is much faster than one forward pass through the network and is highly scalable compared to learning based calibration methods.
In practice, spline

---

Published as a conference paper at ICLR 2021
5 RELATED WORK
Modern calibration methods. In recent years, neural networks are shown to overfit to the Negative Log-Likelihood (NLL) loss and in turn produce overconfident predictions which is cited as the main reason for miscalibration (Guo et al. (2017)). To this end, modern calibration methods can be broadly categorized into 1) methods that adapt the training procedure of the classifier, and 2) methods that learn a recalibration function post training. Among the former, the main idea is to increase the entropy of the classifier to avoid overconfident predictions, which is accomplished via modifying the training loss (Kumar et al. (2018) Mukhoti et al. (2020); (Seo et al. (2019)) label smoothing (Müller et al. (2019): Pereyra et al. 201 ()) and data augmentation techniques (Thulasidasan et al. (2019) Yun
et al. Zhang et al. (2018)).
On the other hand, we are interested in calibrating an already trained classifier that eliminates the need for training from scratch. In this regard, a popular approach is Platt scaling (Platt et al. (1999)
which transforms the outputs of a binary classifier into probabilities by fitting scaled logistic function on held out calibration set. Similar approaches on binary classifiers include Isotonic Regression (Zadrozny& & Elkan (200T), histogram and Bayesian binning (Nacini et al.] (2013); Zadrozny & Elkan (2001)) )) and Beta calibration (Kull et al. (017)), which later extended to the multiclass setting (Guo et al. (2017); Kull et al. 20199) Zadrozny & Eikan (2022). Among these, the most popular method is temperature scaling (Guo et al. (2017)) which learns a single scalar on held out set to calibrate the network predictions. Despite being simple and one of the early works, temperature scaling is the method to beat in calibrating modern networks. Our approach falls into this category, however, as opposed to minimizing loss function, we obtain a recalibration function via ppline-fitting. which directly maps the classifier outputs the calibrated probabilities.
Calibration measures. Expected Calibration Error (ECE) (Nacini et al. (2015) is the most popular measure in the literature, however, it has a weakness that the resulting calibration error depends on the histogram binning scheme such as the bin endpoints and the number of bins. Even though, some improvements have been proposed (Nixon et al.] (2019); Vaicenavicius et al. (2019)), the binning scheme has not been eliminated and it is recently shown that any binning scheme leads to underestimated calibration errors (Kumar et al. (2019); Widmann et al. (2019)) Note that, there are binning-free metries exist such Brier score (Brier 1950)) NLL., and kernel based metrics for the multiclass setting (Kumar et al. (2018); Widmann et al. (2019). Nevertheless, the Brier score and NLL measure a combination of calibration error and classification error (not just the calibration which is the focus). Whereas kernel based metrics, besides being computationally expensive, measure the calibration of the predicted probability vector rather than the classwise calibration error (Kull et al.. (2019) (or top-r prediction) which is typically the quantity of interest. To this end, we introduce binning-fre calibration measure based on the classical KS-test, which has the same benefits as ECE and provides effective visualizations similar to reliability diagrams. Furthermore, KS error can be shown to be a special case of kernel based measures (Gretton et al. (0112)
6 EXPERIMENTS
Experimental setup. We evaluate our proposed calibration method on four different image- classification datasets namely 10FAR-10/100 (Krizhevsky et al. (2009)) SVHN (Netzer et al. (2011)
and ImageNet (Deng et al. (2009) using LeNet (LeCun et al. (1998), ResNet (He et al. (2016)),
ResNet with stochastic depth (Huang et al. (217)). Wide ResNet (Zagoruyko & Komodakis (0166)
and DenseNet (Huang et al. (017g) network architectures against calibrate post training. We use the pretrained network logit:" for spline fitting where choose validation set as the calibration set, similar to the standard practice. Our final results for calibration the test set of all datasets. Since ImageNet does not comprise the validation set, test set is divided into two halves: calibration set and test set. We use the natural cubic spline fitting method (that is, cubic splines with linear run-out) with 6 knots for all our experiments. Further experimental details are provided in the supplementary. For baseline methods namely: Temperature scaling, Vector scaling, Matrix scaling with ODIR (Off-diagonal and Intercept Regularisation) and Dirichlet calibration, we use the implementation of Kull et al. (Kull et al. (2019))
methods that
then reported
ca1 11 libration network
'Pre-trained
logits are obtained from
https://gi thtp/ com rkus NNNN

---

Published as a conference paper at ICLR 2021
Dataset
Model
Uncalibrated
Temp. Scaling
Voctor Scaling
MS-ODIR
Dir-ODIR
Ours (Spline)
Resnet-110
4.750
0.916
0.996
0.977
1,000
0.643
Besmet-110-SD
4.102
0.362
0.430
0.358
0.389
0.269
CIFAR-10
NetoeNet-40
5.493
1.057
Wide Resnet-32
4,475
0,296
0.267
0,305
0.291
0.367
Leact-5
5.038
0.799
0.839
0.646
0.854
0.348
Resnet-110
18.481
1,899
1.827
2.845
2:575
0.575
Resuct-11--SD
15.832
0.748
1.303
1.645
CIFAR-100 100
DenseNet-40
21.156
0.304
0.483
2,350
0.618
0.454
Resnet-32
18.784
1.788
Lenet-5
12.117
1.215
0.768
1,047
2.125
0.391
Densenet-161
5.721
0,744
2.014
4.723
3.103
0,406
ImageNet
Resnet-152
6,544
0.791
1.985
5.805
3.528
0.441
SVHN
Resoet-152-S5
0.852
0.552
0.570
0.573
0.607
0.556
Table 1: KS Error (in %) for top-1 prediction (with lowest in bold and second lowest underlined) on various image classification datasets and models with different calibration methods. Note, our method consistently reduces calibration error to 1% in almost all experiments, outperforming stale-of-the-ar methods.
Dataset
Model
Uncalibrated
Temp. Scaling
Vector Scaling
M5-ODIP
Dir-ODIR
Ours (Spline)
Resnet-110
3.011
0,947
Resnet-110.55
2,716
0.478
0.486
0.401
0.500
0.310
CIFAR-10
DenseNet-40
3,342
0.535
0.543
0.598
0.696
0.695
Wide Resnet- 32
2.669
0.426
0.369
0.412
0.382
0.364
Lenet-5
1,708
0,367
0,279
0.409
0.426
0.837
Resnet-1 110
4.731
1.401
1.436
0.961
1,269
0.371
Resnet-110-SD
3.923
0.481
CIFAR-100
DenseNet-40
5.803
0,305
0.653
0,219
0.135
0.903
Wide Resnet-32
5,349
0,790
1.095
0.6416
0.845
0.372
Lenet-5
2.615
0.571
0.439
0,324
0.799
0.587
Densenet-161 Resoct-152 152
1.689
1.044
1.166
ImageNet
1.793
1,151
1.264
1.660
1,430
0,580
SVHN
Resnet 152-SD SD
0.373
0.226
0.216
0.973
0.218
0.492
Table 2: KS Error (in %) for top-2 prediction (with lowest in bold and second lowest underlined) on various image classification datasets and models with different calibration methods. Again, our method consistently reduces calibration error to < 1% (less then 0.7%, except one case), in all experiments, the only one of the methods to achieve this.
Results. We provide comparisons of our method using proposed KS error for the top most prediction
against state-of-the-arr calibration methods namely temperature scaling (Guo et al. (2017)) vector scaling, MS-ODIR, and Dirichlet Calibration (Dir-ODIR) (Kull et al. (2019) in Table Our method reduces calibration error to 1% in almost all experiments performed on different datasets without any loss in accuracy. It clearly reflects the efficacy of method irrespective of the scale of the dataset as well as the depth the network architecture. It consistently performs better than the recently introduced Dirichlet calibration and Matrix scaling with ODIR (Kull et al. (2019)) in all the experiments. Note this is consistent with the top-1 calibration results reported in Table 15 of (Kull method temperature scaling, against which our method
al. (2019). The closest competitor performs better in 9 out of 13 experiments. Note, in the cases where temperature scaling outperforms our method, the gap KS error between the methods marginal (< 0.3%) and our method is the second best. We provide comparisons using other calibration metrics in the supplementary.
From the practical point of view, it also important for network to be calibrated for top second/third predictions and so on. We thus show comparisons for top-2 prediction KS error in Table 2 An observation similar to the one noted Table I can be made for the top-2 predictions as well. Our method achieves < 1% calibration error in all the experiments. It consistently performs well especially for experiments performed on large scale ImageNet dataset where it sets new state-of of the--hh-art for calibration. We would like to emphasize here, though for some cases Kull et al. (Kull et al. (2019) and Vector Scaling perform better than our method in terms top-2 KS calibration error, overall (considering both 1 and top-2 predictions) our method performs better.
8

---

Published as a conference paper at ICLR 2021
7 CONCLUSION
In this work, we have introduced a binning-free calibration metric based on the Kolmogorov-Smime test to measure classwise or wwithin)-op--7 calibration errors. Our KS error eliminates the shortcom- ings of the popular ECE measure and its variants while accurately measuring the expected calibration error and provides effective visualizations similar reliability diagrams. Furthermore, we introduced simple and effective calibration method based on spline-fitting which does not involve any learning and yet consistently yields the lowest calibration error in majority of our experiments. We believe, the KS metric would be of wide-spread use to measure classwise calibration and our spline method would inspire learning-fre free approaches to neural network calibration. We intend to focus on calibration beyond classification problems as future work.
ACKNOWLEDGEMENTS
The work supported by the Australian Research Council Centre Excellence for Robotic Vision (project number CE140100016). We would also like to thank Google Research and Data61, CSIRO for their support.
REFERENCES
Glenn W Brier. Verification of forecasts expressed terms of probability. Monthly weather review, 78(1):1-3, 1950.
Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In 2009 IEEE conference on computer vision and pattern recognition, pp. 248-255 leee, 2009.
Arthur Gretton, Karsten M Borgwardt, Malte J Rasch, Bernhard Schölkopf. and Alexander Smola. A kernel two-sample test. Journal of Machine Learning Research, 2012.
Chuan Guo, Geoff Pleiss, Yu Sun, and Kilian Weinberger. On calibration of modern neural networks. In Proceedings of the 34th International Conference on Machine Learning- Volume 70, pp. 1321-1330. JMLR. org, 2017.
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE conference computer vision and pattern recognition. pp. 770-778, 2016.
Gao Huang, Zhuang Liu, Laurens Van Der Maaten, and Kilian Q Weinberger. Densely connected convolutional networks. Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 4700-4708, 2017.
Kolmogorov. Sulla determinazione empírica di uma legge di distribuzione. 1933.
Alex Krizhevsky et al. Learning multiple layers of features from tiny images. 2009.
Meelís Kull, Telmo Silva Filho, and Peter Flach. Beta calibration: well-founded and easily implemented improvement on logistic calibration for binary classifiers. In Artificial Intelligence 2017.
and Statistics, pp.
Meelis Kull, Miquel Perello Nieto, Markus Kängsepp, Telmo Silva Filho, Hao Song, and Peter Flach. Beyond temperature scaling: Obtaining well-calibrated multi-class probabilities with dirichlet calibration. In Advances in Neural Information Processing Systems, pp. 12295-12305, 2019.
Ananya Kumar, Percy S Liang, and Tengyu Ma. Verified uncertainty calibration. In Advances in Neural Information Processing Systems, pp. 3787-3798, 2019.
Aviral Kumar, Sunita Sarawagi, and Ujjwal Jain. Trainable calibration measures for neural networks from kernel mean embeddings. In International Conference on Machine Learning, pp. 2805-2814, 2018.

---

Published as a conference paper at ICLR 2021
Yann LeCun, Léon Bottou, Yoshua Bengio, and Patrick Haffner. Gradient-based learning applied to document recognition. Proceedings of the IEEE, 86(11):2278-2224 1998.
Sky McKinley and Megan Levine. Cubic spline interpolation. College of the Redwoods, 1998.
Jishnu Mukhoti, Viveka Kulharia, Amartya Sanyal, Stuart Golodetz, Philip HS Torr, and Puneet K Dokania. Calibrating deep neural networks using focal loss. arXiv preprint arXiv:2002.09437, 2020.
Rafael Müller, Simon Korbliih,, and Geoffrey E Hinton. When does label smoothing help? In Advances in Neural Information Processing Systems, pp. 4696-4705, 2019.
Mahdi Pakdaman Nacini, Gregory Cooper, and Milos Hauskrecht. Obtaining well calibrated prob- abilities using bayesian binning. In Twenty-Ninth AAAI Conference on Artificial Intelligence. 2015.
Yuval Netzer, Tao Wang, Adam Coates, Alessandro Bissacco, Bo Wu, and Andrew Y Ng. Reading digits in natural images with unsupervised feature learning. 2011.
Alexandru Riculescu-Mizil and Rich Caruana. Predicting good probabilities with supervised learning. In Proceedings of the 22nd international conference on Machine learning, 2005.
Jeremy Nixon, Michael W Dusenberry, Linchuan Zhang, Ghassen Jerfel, and Dustin Tran. Measuring calibration in deep learning. In Proceedings of the IEEE Conference on Computer Vision and Puttern Recognition Workshops, pp. 38-41, 2019.
Gabriel Pereyra, George Tucker, Jan Chorowski, Eukasz Kaiser, and Geoffrey Hinton. Regularizing neural networks by penalizing confident output distributions. arXiv preprint arXiv:1701.06544 2017.
John Platt et al. Probabilistic outputs for support vector machines and comparisons to regularized likelihood methods. Advances large margin classifiers, 10()):6-77,, 1999.
Seonguk Seo, Paul Hongsuck Seo, and Bohyung Han. Learning for single-shot confidence calibration in deep neural networks through stochastic inferences. In Proceedings of the IEEE Conference Computer Vision and Pattern Recognition, pp. 9030-9038, 2019.
Nikolai Smirnov. On the estimation of the discrepancy between empirical curves of distribution for two independent samples. 1939.
Sunil Thulasidasan, Gopinath Chemnupati, Jeff Bilmes, Tanmoy Bhattacharya, and Sarah Michalak. On mixup training: Improved calibration and predictive uncertainty for deep neural networks. In Advances in Neural Information Processing Systems, pp. 13888-13899, 2019.
Juozas Vaicenavicius, David Widmann, Carl Andersson, Fredrik Lindsten, Jacob Roll, and Thomas B Schön. Evaluating model calibration in classification. AISTATS, 2019.
David Widmann, Fredrik Lindsten, and Dave Zachariah. Calibration tests in multi-class classification: A unifying framework. In Advances in Neural Information Processing Systems, pp. 12236- 12246, 2019.
Sangdoo Yun, Dongyoon Han, Scong Joon Oh, Sanghyuk Chun, Junsuk Choe, and Youngjoon Yoo. Cutmix: Regularization strategy to train strong classifiers with localizable features. In Proceedings of the IEEE International Conference on Computer Vision, pp. 6023-602600000 6032, 2019.
Bianca Zadrozny and Charles Elkan. Obtaining calibrated probability estimates from decision trees and naive bayesian classifiers. In Icml, volume 1, pp. 609-616. Citeseer, 2001.
Bianca Zadrozny and Charles Elkan. Transforming classifier scores into accurate multiclass probabil- ity estimates. In Proceedings of the eighth ACM SIGKDD international conference on Knowledge discovery and data mining, pp. 694-699, 2002.
Sergey Zagoruyko and Nikos Komodakis. Wide residual networks. arXiv preprint arXiv:1605.07144 2016.
10

---

Published as a conference paper at ICLR 2021
Hongyi Zhang, Moustapha Cissé, Yann N. Dauphin, and David Lopez-Paz. mixup: Beyond empirical risk minimization. In 6th International Conference on Learning Representations, ICLR 2018, 2018.
Jize Zhang, Bhavya Kailkhura, and Han. Mix-n-match: Ensemble and compositional methods for uncertainty calibration in deep learning. ICML, 2020.
Appendices
Here, we first provide the proof of our main result, discuss more about top-r' calibration and spline- fitting, and then turn to additional experiments.
A PROOF OF PROPOSITION 4.1
We first restate our proposition below.
Proposition A.2. If (ft(t) = P(Y = k. fx(X) S s(() as in (14) of the main paper where s(t) is the I-th fructile score. Then H/ (1))) = (x()) s()), where h1 [00--d/dhl dh/dl.
Proof. The proof using the fundamental relationship between the Probability Distribution Function (PDF) and the Cumulative Distribution Function (CDF) and it is provided here for completeness. Taking derivatives, we see (writing P(k) instead of P(Y k)):
(((D) = P(k, fx(X) = s(()) 8((1)
= P(k| Jx(X) = =())) P((((X) = x(1)
P(k [x(X) = =())) d
(P(J(() S
(15)
d
P(K fx() s(t)) (t)
P(K fx(X) s(t)
The proof relics on the equality P(fx (X) S st) = t. words: s(t) is the value that a fraction of the scores are less than equal. This equality then says: the probability that score is less than or equal to the value that a fraction of the scores lie below, is (obviously) equal to
((()))=t
B MORE ON TOP-r AND WITHIN-TOP-> CALIBRATION
In the main paper, definitions of top-r and within-top-r calibration are given in equations (4) and (5). Here, few more details are given of how calibrate the classifier f for top-r and within-top-r calibration.
The method of calibration using splines described in this paper consists of fitting a spline to the cumulative accuracy, defined h; in equation (11) l) in the main paper. For top-r classification, the method is much the same as for the classification for class k. Equation (11) is replaced by sorting the data according the r-th top score, then defining
ho hg = 0,
h; h;:-1 + 1 1)/N
(16)
h; h (x;)N
where (--r) and (x,, are defined in the main paper, equation (3). These sequences may then be used both as a metric for the correct top-r calibration and for calibration using bllin-fitttigg as described.
11

---

Published as a conference paper at ICLR 2021
For within-top-r calibration, sorts the data according to the sum of the top scores, namely Ex=1 (x=))(x)) then computes
ho = ho = =0,
h; h4-1 + (/ = =1)/N,
(17)
h. = - Σ (x.)
As before, this can be used as a metric, or as the starting point for within-top-r calibration by our method. Examples this type of calibration (graphs for uncalibrated networks in Zig fig is given in the graphs provided in fig 8 and fig 10 for within-top-2 predictions and within-top-3 predictions respectively.
It is notable that if classifier is calibrated in the sense of equation (1) in the main paper (also called multi-clas-calliraaeed then is also calibrated for top-r and within-top-r classification.
C LEAST SQUARE SPLINE FITTING
Least-square fitting using cubic splines is known technique. However, details are given here for the convenience of the reader. Our primary reference is (McKinley & Levine (1998), which adapt to least-squares fitting. We consider the case where the knot-points are evenly spaced.
We change notation from that used in the main paper by denoting points by (2),3) instead of (u, v)- No Given a point ar, the corresponding spline value is given by = a(x) My, where ý is the vector of values Ú. The form of the vector (xx) and the matrix are given in the following.
Thus, given knot points (f;, Gr (=) one is required to fit some points (r4, Wi)i=1
The form of the matrix M is derived from equation (25) in McKinley & Levine 1998). Define the matrices
4
1
1
4
1
2
1
4
6
1 2 1
A
B
h2
4
1 4
1 - 1
where h is the distance between the knot points. These matrices are of dimensions K - x - and K K respectively. Finally, let be the matrix
K A
B
M
0g
IK
Here, 0к is vector of zeros of length K, and IÆ*K is the identity matrix. The matrix M has dimension 2K x K.
Next, let the point x lie between the knots j and j and let x St. Then define the vector a(x) by values
fi =-u²/(6h) + u²² u²/2 ha/3.
0j+1 v² ///(hh) hu/6 6
Uj+K -u/h +//+1.
Uj+14K u/h,
with other entries equal to 0.
12

---

Published as a conference paper at ICLR 2021
Dataset
Image
Size
class
Calibration
Test
CIFAR-10
32 32
10
5000
10000
CIFAR-100
32
100
5000
10000
SVHN
32 x 32
10
6000
26032
ImageNet
224 X 224
1000
25000
25000
Table 3: Dataset splits used for all the calibration experiments. Note, "calibration" set is used for spline fitting in our method and calibration for the baseline methods and then different methods are evaluated on "test" set.
Dataset
Model
Uncalibrated
Temp. Scaling
Vector Scaling
MS-ODIR
Dir-ODIR
Ours (Spline)
Resuct-110
0.097
0.176
Resnet-110-SD
1.423
0.111
0.089
0.082
0.073
0.104
NenseNet-40
2.256
Wide Resnet-32
1.812
0,145
0.105
0.124
0.139
0.537
Lenet-5
3.545
0.832
0.831
0.631
0.804
0.670
Resnet-110
14.270
0.885
0.649
1.425
1.190
0.503
Resnet- 110--D1DDDDD
CIFAR-100 100
DenseNet-40
15.901
0.4.7
0.368
2,205
0.518
0.724
Wide Resnet-32
14.078
0.414
0,548
1,915
1,099
1.017
Lenet-5
14.713
0.787
1.249
0.643
2,682
0.518
Densenet-161
4,266
1,051
0.868
3,372
2,536
0.408
ImageNet
Resact-152
4,851
1.167
0.776
4.093
2,839
0.247
SVHN
Resoct-1524 152-SD
0.485
0.388
0.410
0.407
0.388
0.158
Table 4: Within-top-2 predictions. KS Error (in %6 within-top-2 prediction (with lowest in bold and second lowest underlined) on various image classification datasets and models with different calibration methods. Note, for this experiment we use 14 knots for spline fitting.
Then the value of the spline is given by
a(x) Ty
as required. This allows to fit the spline (varying the values y) points (x, y/) by least-squares fit, as described in the main paper.
The above description for so-called natural (linear-runuut) splines. For quadratic-runout cubic- runout splines the only difference is that the first and last rows of matrix are changed see Mcelleyyy Levine (1998) for details.
As described in the main paper, it is also possible to add linear constraints to this least-squares problem, such as constraints on derivatives of the spline. This results in linearly-constrained quadratic programming problem.
D ADDITIONAL EXPERIMENTS
We first provide the experimental setup for different datasets in Table Note, the calibration set used for spline fitting in our method and then final evaluation is based on unseen test set.
We also provide comparisons of our method against baseline methods for within-top-2 predictions (equation 5 of the main paper) in Table using KS error. Our method achieves comparable or better results for within-top t predictions. should be noted that the scores for top-3 (f(-3) (x)) or even top-4, top-5, etc., are very close zero for majority of the samples (due to overconfidence of top-1 predictions). Therefore the calibration error for top-r with > 2 predictions is very close to zero and comparing different methods with respect to it is of little value. Furthermore, for visual illustration, provide calibration graphs of top-2 predictions in fig and fig for uncalibrated and calibrated network respectively. Similar graphs for top-3, within-top-2 and within-top-3 predictions presented in figures
10
We also provide classification accuracy comparisons for different post-hoc calibration methods against method if we apply calibration for all 1, ... ... K predictions for K K-class classification problem in Table We would like to point out that there is negligible change in accuracy between the calibrated networks (using method) and the uncalibrated ones.
13

---

Published as a conference paper at ICLR 2021
Test Class 2] Unialbrated
KS-errar 3.343%. Probabiitt 5. 0800%
60
Canditaic Stat
603
Scar
Sout
Cunulative Soare Probakiity
Candicas Poballyy
Pobshdly
Piduuiiity
Spote Proko/iity
643
Ouuuiiit Sun
Qutxiiiie Pobality
688
600
Percentle
Cumolriie Scree
Perconnile
Scon
60
(8)
Figure 3: Top-2 predictions, Uncalibrated. Calibration graphs for an uncalibrated DenseNet-40 (Huang) et al. (2017)) trained on CIFAR- 10 for top-2 class with a KS error of 3.343% on the test set. Here (a) shows the plot of cumulative score and probability versus the fructile of the test set, (b) shows the same information with the horizontal axis warped that the sunulative-scon graph is straight line. This is created scatter plots of cumulative (score, score): blue and (score, probability): orange. If the network perfectly calibrated, the probability line will a straight line coincident with the (score, score) line. This shows that the network substontially overestimating (score) the probability of the computation. (c) and (d) show plots of nonncummlative) score and probability plotted against fractile, score. How these plots are produced is described in Section 4 of main paper.
Calib Clasel-2] Calibented KS-eman 0.243%, Probabiitt 4.220%
Candicas Scrt Candicas Polabily
Dandicas Sowr
Scar
Scer
Candicas Tuballly
Cunabaire Scoee Prolehitiy
Spare Protahiit
601
Percentlle
Cunulatte Store
Test Clasa-2] Calibrated KS emrr 0,600%, Probabiitty 5.080%
Scet
Clnstative Scare Prububiity
Canulacio Pubabiiky
Pububiik
Pubuuddiyy
1.4
Stort Prolahiley
6.2
402
Pereanilc
Cumslliine Scrte
Percanilc
Sconc
64)
(b)
60
(4)
Figure 4: Top-2 predictions, Calibrated. The result of the spline calibration method, on the example given in fig for top-2 calibration. A recalibration function 7: IR with (f((x) (see Section of main paper). As is seen, the network is now almost perfectly calibrated when tested on the "calibration" set (top row) used to calibrate it. In bottom row. the recalibration function is tested further set "test" r It is seen that the result is not perfect, but much better than the original results in fig
used adjust scores, replacing fx (x)
14

---

Published as a conference paper at ICLR 2021
Class(33
KS-cmor
Prohdhility 13
Candaitve Sivee Febboitty
0.3
6412
6112
2.3
6418
Score
Candeancoon Candennchhsasill
0.33
Scooes
6.24
LG
1,000
14.00
Colo
0,000
0.55
8.0
0.17
4.55
8.5
Parcenilc
Carmulatin
Pereemille
(b)
(6)
Figure 5: Top-3 predictions, Uncalibrated. Calibration graphs for an uncalibrated DenseNet-40 trained on CIFAR- R-10 for top-3 class with KS error of 1.277% the test set. Here (a) shows the plot cumulative horizontal axis
score and probability versus the fractile of the test set, (b) shows same information warped so that the cumulative- sonooe score graph is a straight line. (c) and (d) show plots of (non-cumuul cumulative) score and probability plotted against fractile, or score.
Calib Cleas CCalimmtedd
KS-emwr 0,270%
Probahility 2400%
Chacsatiee Scre
6012
Cameltivv Seace
Soa
Cumarriiv Scoee Prokotiity
Clexslatie Trbiiiilly
Canalativ Priiaiiity
Probabilly
Probotiity
0.3
k00
0/14
6.03
Percentile
Camilativ Score
Percentie (+)
Ncore (4)
(+)
(b)
Test Class Calibrated
Probabiiit-
Chacslatio
Cansaatti Tobubiily
6C14
Curaliato Paiukliy
Canallbbv Seaue
Scor
Cunutativ Scoce Erobeltity
6117
0.09
61:0
3.00
Figure Top-3 predictions, Calibrated. The result of the spline calibration method, on the example given in fig 5 for top-3 calibration. A recalibration function IR. - IR is used to adjust the scores, replacing fa (x) with (x)(x)) As is seen, the network is now almost perfectly calibrated when tested on the "calibration" set
(top row) used calibrate In bottom row, the recalibration function is tested on further "test". It seen that the result is not perfect, but much better than the original results in fig 5
15

---

Published as a conference paper at ICLR 2021
Test Class 2] Uncalibrated KS-2nor 2256%, Piahability 97.50%
Canabitia Sire
Dreslaio Sen
S Priiailtyy
Canasition Pabikily
Crealaioe Priuuiliy
Cunuaatrv Score Evokubitts
CC'
Score
Within-top-2 predictions, Uncalibrated. Calibration graphs for an uncalibrated DenseNet-40 trained on CIFAR- 10 for within-top-2 predictions with KS error of 2.256% on the test set. Here (a) shows the plot of cumulative score and probability with the horizontal (non cumulative) score and probability plotted against fractile, or score.
Figure 7:
the fructile the test (b) shows the same information warped that cumulative-sor score graph straight line. (c) and (d) show plats of
Class(-2] Calihrated
KS-eror 0 0144% Profubiliy-48 04.05 0405%
Camallinc Soat
Canalline Bubihiik
Clouaaave Score Poobuhiiyy
Suere
Potubday
Peraentlc
Cuntabative Soore
Percentile
Samm
(C)
Test Classl-] Calibrated
Probubilit-97.5500
Comuuatve Spore Polabhiity
Scoees
62-
02-
Scere
Pobebblly
27
Percemie
Conrulative Scoce
Percetill
Score
64)
(6)
(c)
(20
Figure 8: Within-top-2 predictions, Calibrated. The result the spline calibration method, the example IR used adjust the scores, replacing fe(x) with 7(x(xx) As is seen, the network is now almost perfectly calibrated when tested "calibration" set (top row) used to calibrate it. In bottom row, the recalibration function is tested on a further set "test". It is seen that the result is not perfect, but much better than the original results in fig 7..
given in fig 7 for within-top-2 calibration. A recalibration function
16

---

Published as a conference paper at ICLR 2021
Test Class Uncolibrated 0.83%
Probabilitt uog 97015
13
Cxndlaiee
100
Cundatvve Score Prooatall
Score Photort.tt
02-
Pobebbdyy
Percemtle
Cosrulative Scoce
Percettlle
Score
(6)
(4)
Figure 9: Within-top-3 predictions, Uncalibrated. Calibration graphs for uncalibrated DenseNet-40 trained CIFAR-IO for within-top-3 predictions with KS error 0.983% the set. Here (a) shows the plot of cumulative score and probability versus the fractile of the test set, (b) shows the same information with the horizontal axis warped so that the cumulative sccor score graph is a straight line. (c) and (d) show plots of (non-cumulin cumulative score and probability plotted against fractile, score.
Callb Class Calihmted Prolobility49.222
12-
Comuubivvee Score Prooabiio
6:51
6.0
0.-
6.0
02-
0:00
0.13
Smre
Probbdlly
6.0
Perccuile
Custalative Stote
Percesille (6)
Score (4)
(0)
(b)
Test Classi 3] Calibrated KS-emor 0368%, Probabildt
Clamaiatvvs Caaaainive Praiabiiyy
Creulati San
118
Scon Trchliltyy
Cuculati Proulltty
Cunulativ Score Probehiity
Score: Frotoliity
02
Pubbbiibyy
840
Perozttic
Comuabaiiee
Persentll
Same
Figure 10: Within-top-3 predictions, Calibrated, The result of the spline calibration method, on the example given in fig for within-top-3 calibration. A recalibration function IR - IR. is used adjust the scores, replacing fe(x) with > x(xx()(()))))))))))))))))( As seen, the network is now almost perfectly calibrated when tested "calibration" set (top row) used to calibrate In bottom row, the recalibration function is tested on a further set "test" It is seen that the result is not perfect, but much better than the original results in fig Mt.
17

---

Published as a conference paper at ICLR 2021
Dataset
Model
Uncalibrated
Temp. Scaling
Voctor Scaling
MS-ODIR
Dir-ODIR
Ours (Spline)
Resnet-110
93.56
93.56
93.50
93.53
93.52
93.55
Besmet-110-SD
94.04
94.04
94.04
94.18
94.20
94.05
CIFAR-10
Net4eNet-40
Wide Resnet-32
93.93
93.93
94.21
94.22
94.22
93.76
Leact-5
72.74
72.74
74.48
74.44
74.52
72.64
Resnet-110
71 .48
71.48
71.58
71.55
71.62
71.50
Resuct-11O-SD
72.83
72.83
73.60
CIFAR-100 100
DenseNet-40
70.00
70.00
70.13
70.40
70.24
70.17
Resnet-32
73.82
Lenet-5
33.59
33.59
36.42
37.58
37.52
33.55
Densenet-161
77.05
77.05
76.72
77.15
77.19
77.05
ImageNet
Resnet-152
76.20
76.20
75.87
76.12
76.24
76.07
SVHN
Desoct-152-SD
98.15
98.15
98.13
98.12
98.19
98.17
Table 5: Classification (top-1) accuracy (with highest in bold and second highest underlined) post calibration on various image classification datasets and models with different calibration methods. Note, only negligible change in accuracy is observed in our method compared to the uncalibrated networks.
Dataset
Model
Uncalibrated
Temp, Scaling
Vector Scaling
MS ASSODDR
Dir Pir-ODIR
Ours (Spline)
Resnet-110
4,750
1.224
1.092
1.276
1.240
Resnet-1106 110-SD
4.135
0.777
0,752
0.684
0,859
0.992
CIFAR-10
DenseNet-40
5,507
1.006
1.207
1.268
1.389
Wide Resnet-32
4,512
0,905
0.852
0,941
0.965
1,003
Lenel-5
5.188
1.999
1.462
1.504
1.300
1.333
Resnet-110
18.480
2.428
2.722
3.011
2.806
1.68
CIFAR-100 100
DenseNet-40
159
1.255
1.598
2,855
1.410
2.114
Wide Resnet-32
18.784
1.667
1.785
2,870
2.128
1.672
Lenet-5
12.117
1.535
1,350
1,696
2.159
1,029
5.720
2,059
2,637
ImageNet
Resnet- 152
6.545
2.166
2,641
5.377
4.556
0.913
SVHI
Resnet 152 SD
0.877
0.675
0.630
0.646
0.651
0.832
Table 6: ECE top-1 predictions (in %) using 25 bins (with lowest in bold and second lowest underlined) on various image classification datasets models with different calibration methods. Note, for this experiment we use 13 knots for spline fitting.
For the sake of completeness, we present calibration results using the existing calibration metric, Expected Calibration Error (ECE) (Naeini al. (2015) Table We would like to reiterate the fact that ECE metric is highly dependent on the chosen number of bins and thus does not really reflect true calibration performance. To reflect the efficacy of our proposed calibration method, we also present calibration results using other calibration metrics such as recently proposed binning free measure KDE-ECE (Zhang et al. (2020)), ), MCE (Maximum Calibration Error) (Guo et al. (2017)) and Brier Scores for top-1 predictions ImageNet dataset in Table 7 Since. the original formulation of Brier Score for multi-class predictions highly biased on the accuracy and is approximately similar for all calibration methods, we hereby top-1 Brier Score which is the mean squared error between top-1 scores and ground truths for the top-1 predictions (1 if the prediction is correct and otherwise). be clearly observed that approach consistently outperforms all the baselines different calibration measures.
18

---

Published as a conference paper at ICLR 2021
Calibration Metric
Model
Uncalibrated
Temp. Scaling
MS ODIR
Dir-ODIR
Ours (Spline)
Densenct-1es 161
0.03786
0.01501
0,02874
0.02979
0.00637
KDE-ECE
Resnet-13 -552
0.04650
0.01864
0.03448
0.03485
0.00847
Densenct-16 161 Resnet-
0.13123
0.05442
0.09077
0.09653
0.06289
MCE
0.15930
0.11201
0.09868
0.04950
Densenct- 161
0.12172
0.11852
0.11982
0.11978
0.11734
Brier Score
Resnet-152
0.12626
0.12145
0.12406
0.12308
0.12034
Table 7: Calibration Error using other different metrics such as binning-free KDE-ECE Zhang et al. (2200) J.
MCE (Maximum Calibration Error) (Guo al.))22000 (2017)) and Brier Score for top-1 predictions (with lowest in bold and and second lowest underlined) on ImageNet dataset with different calibration methods. Note, for this experiment use 6 knots for spline fitting.
19


Reviews:
[{"review_id": "sW1-EF_mcTx", "reviewer": "AnonReviewer4", "summary": "", "questions": "", "limitations": "", "rating": 5, "confidence": 4, "soundness": null, "presentation": null, "contribution": null, "strengths": "", "weaknesses": "", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "", "methods_and_evaluation_criteria": "", "theoretical_claims": "", "experimental_designs_or_analyses": "", "relation_to_broader_scientific_literature": "", "essential_references_not_discussed": "", "other_strengths_and_weaknesses": "", "other_comments_or_suggestions": "", "questions_for_authors": "", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "main_review": "", "summary_of_the_paper": "", "summary_of_the_review": "", "strength_and_weaknesses": "", "limitations_and_societal_impact": "", "review_text": "The paper proposes a post re-calibration spline-based approach for the re-calibration of multiclass predictions.  Experiment results on image datasets are provided and evaluated according to the Kolmogorov–Smirnov (KS) statistic. \n\n**Strengths**:\n - The proposed binning-free calibration measure is a good idea and widely used in binary classification problems\n\n- As expected, experimental results demonstrate that optimizing calibration with a spline-based approach results in better calibration\n\n**Weaknesses**:\n\n*Inconsistent notation*:\n-  The authors should stick to either $x $ or $X$\n-  The definition of the KS statistic is inconsistent with standard formulations Eq (8). Also, the paper claims to obtain the maximum value at $\\sigma=1$; this is a strong assumption.\n\n*Weak experiments*:\n- Why KS statistic and not Wasserstein or calibration slope?\n-  Eq (11) assumes $f_k(x_i)$ are distinct, which is not always the case.\n- Calibration and accuracy are orthogonal concerns, where the proposed post re-calibration approach is prone to overfit on calibration at the expense of accuracy (and this is the case, as experimental results show a loss in accuracy)\n-  Demonstrating an approach that accounts for the calibration-accuracy tradeoff is crucial\n- Extending the proposed approach to regression problems would strengthen the submission\n- A  qualitative discussion on:\n1)  Why Temp. Scaling is better calibrated in some instances\n2)  Why calibration results of proposed solution (and alternatives) vary across different network architectures for the same dataset\n3) Why the proposed approach drops in performance between top-1 and top-2 predictions\n- The proposed re-calibration approach may not scale well with large datasets; a computational complexity comparison against alternatives is crucial", "extra_scores": {}, "extra_text": {}}, {"review_id": "oebnWdKOUtk", "reviewer": "AnonReviewer2", "summary": "", "questions": "", "limitations": "", "rating": 8, "confidence": 4, "soundness": null, "presentation": null, "contribution": null, "strengths": "", "weaknesses": "", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "", "methods_and_evaluation_criteria": "", "theoretical_claims": "", "experimental_designs_or_analyses": "", "relation_to_broader_scientific_literature": "", "essential_references_not_discussed": "", "other_strengths_and_weaknesses": "", "other_comments_or_suggestions": "", "questions_for_authors": "", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "main_review": "", "summary_of_the_paper": "", "summary_of_the_review": "", "strength_and_weaknesses": "", "limitations_and_societal_impact": "", "review_text": "Pros: originality, clarity, technical correctness.\nCons: experiments need some clarifications.\n\nCalibration typically relies heavily on binning the data, both for the calibration itself  (Histogram Binning) and how to measure its quality (ECE). Thus both operations suffer from sampling issues that are a cause for both bias and variance. The idea to rather perform the analysis using cumulative distributions would seem obvious, as it has been tried on so many other problems, but I have not seen it used for calibration. They do it for both calibration and its measure:\n-\tThe use of the Kolmogorov-Smirnov test to measure calibration between the target and the output distributions.\n-\tSpline fitting of the cumulative distribution to compute its derivative\nAs the implementation details are far from obvious , there are several original contributions, especially in implementing the splines.\n\nI found the description both very clear and concise, switching between intuition and equations.\nThe only part I found confusing is the second paragraph of section 4.2 (“One method of calibration..”). Fortunately, the next paragraph gives a very simple intuitive explanation by just stating how it is implemented.\n\nExperiments are very comprehensive and show improvements over Temp scaling and other methods. However, there are also some results that contradict previously reported experiments and need to be clarified:\n-\tBesides Temp scaling, the main other methods are borrowed from Kull et al, so one could expect some consistency. However ECE results from Table 6 look very different from Table 3 in Kull et al. I assume these are different types of ECE: confidence vs. class-wise? In Table 1, KS result for the ODIR methods of Kull et Al are much worse than Temp scaling, in particular for CIFAR-100 and Imagenet. This contradicts results reported in Table 2 (this paper) and Table 3 (Kull et al) and should be explained.\n\n-\tI am no expert in image classification,  but the 70% accuracy reported for CIFAR-100 seems way below current numbers, which have exceeded 80% since 2017, in particular for the proposed architectures (for instance Wide Resnet or DenseNet) https://benchmarks.ai/cifar-100.  However these numbers seem to be consistent with what is reported by Kull et al (Table 18 in https://arxiv.org/pdf/1910.12656.pdf), so I assume the issue comes from borrowing their architecture and scores. While this should not impact comparative results, it would have been more satisfactory to use baseline architectures that match the state-of-the-art.\n\nAdditional experiments or discussions on the following would greatly help:\n-\tAs the spline method is not always better than Temp scaling, how do they compare from a computational viewpoint? How long does the binary search over thousands of calibration examples take compared to the DNN feed-forward?\n-\tFrom Tables 1,2 and 6, KS error and ECE rank methods quite differently. One reason one should trust KS more is that it does not depend on binning choices, and rely on a time-proven test. But could one come up with an experiment that shows that KS is provably more reliable? \n\nPost rebuttal: I have read the authors responses with to my 4 questions, and appreciate how detailed and honest they are. They satisfy my concerns.\n", "extra_scores": {}, "extra_text": {}}, {"review_id": "ThYCYAtWQqC", "reviewer": "AnonReviewer1", "summary": "", "questions": "", "limitations": "", "rating": 7, "confidence": 4, "soundness": null, "presentation": null, "contribution": null, "strengths": "", "weaknesses": "", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "", "methods_and_evaluation_criteria": "", "theoretical_claims": "", "experimental_designs_or_analyses": "", "relation_to_broader_scientific_literature": "", "essential_references_not_discussed": "", "other_strengths_and_weaknesses": "", "other_comments_or_suggestions": "", "questions_for_authors": "", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "main_review": "", "summary_of_the_paper": "", "summary_of_the_review": "", "strength_and_weaknesses": "", "limitations_and_societal_impact": "", "review_text": "The paper presents a post-hoc calibration method for deep neural net classification. The method proposes to first reduces the well-known ECE score to a special case of the Kolmogorov-Smirnov (KS) test, and this way solves the dependency of ECE on the limiting binning assumption. The method proposes next to recalibrate the classification probabilities by fitting a cubic spline to the KS test score.\n\nStrengths:\n * The proposed approach is a clearly novel solution to an essential problem for the safety-critical use of deep learning.\n * The paper presents the material in a very clear and neat way, following an excellent scientific writing practice.\n * Both the KS test based treatment of network calibration and the elegant way to improve the calibration by cubic spline fitting are interesting and likely to attract the attention of the deep learning uncertainty community.\n * The paper presents an exhaustive set of experiments that report performances of quite deep state-of-the-art network architectures on four different benchmark tasks. It also provides comparisons against a decent number of state-of-the-art calibration methods. The results demonstrate the benefits of the proposed method.\n\n(Minor) Weaknesses: The paper can be improved with a few small adjustments in the presentation:\n\n * The so-called \"python semantics\" notation in Sec 2 only introduces complexity and does not bring any concrete value to the story line. What is wrong with denoting the r-th top score simply as f^{(n)}. Why do we need the minus? We can simply assume that the first element of the sorted list is the top score.\n\n * Why do we need Proposition 4.1 and its proof (sketch and full) in this paper? It only echoes the standard relationship between a PDF and CDF. The former is the derivative of the latter.\n\n * Although the results in Tables 1 and 2 are groundbreaking in favor of the proposed method, they are calibration scores based on the KS score. That is only one way of measuring the calibratedness of a network, and furthermore that is the score the proposed method is maximizing. It would be interesting to see how well the proposed method generalizes across other calibration scores that may highlight complementary aspects of the uncertainty treatment capabilities of the predictor, such as the Brier score.\n\nOverall, this is a solid piece of work that qualifies to appear at the ICLR'21 proceedings.", "extra_scores": {}, "extra_text": {}}, {"review_id": "LgPTXcR4kp2", "reviewer": "AnonReviewer3", "summary": "", "questions": "", "limitations": "", "rating": 8, "confidence": 4, "soundness": null, "presentation": null, "contribution": null, "strengths": "", "weaknesses": "", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "", "methods_and_evaluation_criteria": "", "theoretical_claims": "", "experimental_designs_or_analyses": "", "relation_to_broader_scientific_literature": "", "essential_references_not_discussed": "", "other_strengths_and_weaknesses": "", "other_comments_or_suggestions": "", "questions_for_authors": "", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "main_review": "", "summary_of_the_paper": "", "summary_of_the_review": "", "strength_and_weaknesses": "", "limitations_and_societal_impact": "", "review_text": "The authors present a binning-free calibration measure from a Kolmogorov-Smirnov-based test. Besides, the cumulative probability distribution is estimated using a spline-based fitting from percentiles. The approach allows correcting the probability estimation from trained deep learning models. The paper is clear and well-founded. \n", "extra_scores": {}, "extra_text": {}}]

Author rebuttal:

Meta-review: Many papers have been written on calibrating neural networks recently.  This paper presents a definition of calibration that is more robust than the popular ECE measure while also being more discerning than the Brier score.  Then it proposes a practical spline-based method of post-editing the output softmax scores to make them more calibrated.  The method is shown to be better than existing methods both on their measure and established measure (thanks to reviewer's questions on that.).
The paper should be of much interest to the community.
Decision: Accept (Poster)