Title: DISTANCE-BASED LEARNING FROM ERRORS FOR CONFIDENCE CALIBRATION

Abstract: Deep neural networks (DNNs) are poorly calibrated when trained in conventional ways. To improve confidence calibration of DNNs, we propose a novel training method, distance-based learning from errors (DBLE). DBLE bases its confidence estimation on distances in the representation space. In DBLE, we first adapt prototypical learning to train classification models. It yields a representation space where the distance between a test sample and its ground truth class center can calibrate the model's classification performance. At inference, however, these distances are not available due to the lack of ground truth labels. To circumvent this by inferring the distance for every test sample, we propose to train a confidence model jointly with the classification model. We integrate this into training by merely learning from mis-classified training samples, which we show to be highly beneficial for effective learning. On multiple datasets and DNN architectures, we demonstrate that DBLE outperforms alternative single-model confidence calibration approaches. DBLE also achieves comparable performance with computationally-expensive ensemble approaches with lower computational cost and lower number of parameters.

1. INTRODUCTION:

Deep neural networks (DNNs) are being deployed in many important decision-making scenarios (Goodfellow et al., 2016) . Making wrong decisions could be very costly in most of them (Brundage et al., 2018) -it could cost human lives in medical diagnosis and autonomous transportation, and it could cost significant business losses in loan categorization and sales forecasting. To prevent these from happening, it is strongly desired for a DNN to output confidence estimations on its decisions. In almost all of the aforementioned scenarios, detrimental consequences could be avoided by refraining from making decisions or consulting human experts, in the cases of decisions with insufficient confidence. In addition, by tracking the confidence in decisions, dataset shifts can be detected and developers can build insights towards improving the model performance.

However, confidence estimation (also referred as 'confidence calibration') is still a challenging problem for DNNs. For a 'well-calibrated' model, predictions with higher confidence should be more likely accurate. However, as studied in (Nguyen et al., 2014; Guo et al., 2017) , for DNNs with conventional (also referred as 'vanilla') training to minimize the softmax cross-entropy loss, the outputs do not contain sufficient information for well-calibrated confidence estimation. Posterior probability estimates (e.g. the softmax outputs) can be interpreted as confidence estimation, but it calibrates the decision quality poorly (Gal & Ghahramani, 2016) -the confidence tend to be large even when the classification is inaccurate. Therefore, it would be desirable if the training approach is redesigned to make its decision making more transparent, thus providing more information for accurate confidence calibration.

In this paper, we propose a novel training method, Distance-based Learning from Errors (DBLE), towards better-calibrated DNNs. DBLE learns a distance-based representation space through classification and exploits distances in the space to yield well-calibrated classification. Our motivation is that a test sample's location in the representation space and its distance to training samples should contain important information about the model's decision-making process, which is useful for guiding confidence estimation. However, in vanilla training, since both training and inference are not based on distances in the representation space, they are not optimized to fulfill this goal. Therefore, in DBLE, we propose to adapt prototypical learning for training and inference, to learn a distance-based representation space through classification. In this space, a test sample's distance to its ground-truth class center can calibrate the model's performance. However, this distance cannot be calculated at inference directly, since the ground truth label is unknown. To this end, we propose to train a separate confidence model in DBLE, jointly with the classification model, to estimate this distance at inference. To train the confidence model, we utilize the mis-classified training samples during the training of the classification model. We demonstrate that on multiple DNN models and datasets, DBLE achieves superior confidence calibration without increasing the computational cost as ensemble methods.

2. RELATED WORK:

Many studies (Nguyen et al., 2014; Guo et al., 2017) have shown that the classification performance of DNNs are poorly-calibrated under vanilla training. One direction of work to improve calibration is adapting regularization methods for vanilla training. Such regularization methods are often originally proposed for other purposes. For example, Label Smoothing (Szegedy et al., 2016) , which is proposed for improving generalization, has empirically shown to improve confidence calibration (Müller et al., 2019) . Mixup (Zhang et al., 2017) , which is designed mostly for adversarial robustness, also improves confidence calibration (Thulasidasan et al., 2019) . The benefits from such approaches are typically limited, as the modified objective functions do not represent the goal of confidence estimation. To directly minimize a confidence scoring objective, Temperature Scaling (Guo et al., 2017) , modifies learning by minimizing a Negative Log-Likelihood (Friedman et al., 2001) objective on a small training subset. It yields better-calibrated confidence by directly minimizing an evaluation metric of the calibration task. However, since it requires training set to be split for the two tasks, classification and calibration, it results in a trade-off -if more training data is used for calibration, then the model's classification performance would drop because less training data are left for classification.

Bayesian DNNs constitute another direction of related work. Bayesian DNNs aim to directly model the posterior distribution for a test sample given the training set (Rohekar et al., 2019) . In Bayesian DNNs, since getting the posterior of large amount of parameters is usually intractable, different approximations are applied, such as Markov chain Monte Carlo (MCMC) methods (Neal, 2012) and variational Bayesian methods (Blundell et al., 2015; Graves, 2011) . Therefore, the calibration of Bayesian DNNs heavily depends on the degree of approximation and the pre-defined prior in variational methods. Moreover, in practice, Bayesian DNNs often yield prohibitively slow training due to the slow convergence of the posterior predictive estimation. (Lakshminarayanan et al., 2017) . Recent work on Bayesian DNNs (Heek & Kalchbrenner, 2019) reports that the training time of their model is an order of magnitude higher than vanilla training. As Bayesian-inspired approaches, Monte Carlo Dropout (Gal & Ghahramani, 2016) and Deep Ensembles (Lakshminarayanan et al., 2017) are two widely-used methods since they only require minor changes to the classic training method of DNNs and are relatively faster to train.

3. LEARNING A DISTANCE-BASED SPACE FOR CONFIDENCE CALIBRATION:

We first introduce how DBLE applies prototypical learning to train DNNs for classification. Then, we explain that under this new training method, a distance-based representation space can be achieved to benefit confidence calibration.

3.1. PROTOTYPICAL LEARNING FOR CLASSIFICATION:

DBLE bases the training of the classification model on prototypical learning (Snell et al., 2017) . Prototypical learning is originally proposed to learn a distance-based representation space for few-shot learning (Ravi & Larochelle, 2016; Oreshkin et al., 2018; Xing et al., 2019) . In prototypical learning, both training and prediction solely depend on the distance of the samples to their corresponding class 'prototypes' (referred as 'class centers' in the paper) in the representation space. It trains the model with the goal of minimizing the intra-class distances, whereas maximizing inter-class distances such that related samples are clustered together. We adapt this training method for classification training in DBLE. Subsequent subsections describe the two main components of prototypical training: episodic training and prototypical loss for classification. Later, we explain how to run inference at test time and why it leads to a representation space that benefits confidence calibration.

3.1.1. EPISODIC TRAINING:

Vanilla DNN training for classification is based on variants of mini-batch gradient descent (Bottou, 2010) . Episodic training, on the other hand, samples K-shot, N -way episodes at every update (as opposed to sampling a batch of training data). An episode e is created by first sampling N random classes out of M total classes1 , and then sampling two sets of training samples for these classes: (i) the support set S e = {(s j , y j )} At episode e, the model is updated to map the query x i to its correct label y i , with the help of support set S e . The model is a function parameterized by θ and the loss is negative log-likelihood of the ground-truth class label of each query sample given the support set according to Eq. 1.

3.1.2. PROTOTYPICAL LOSS:

How does the support set S e help the classification of query samples at episode e? We firstly employ the classification model, f : R nv → R nc to encode inputs in a representation space, where θ are trainable parameters.

Prototypical training then uses the support set S e to compute the center for each class (in the sampled episode). The query samples are classified based on their distance to each class center in the representation space. For every episode e, each center c k is computed by averaging the representations of the support samples from class k:

EQUATION

where S k e ⊂ S e is the subset of support samples belonging to class k. The prototypical loss calculates the predictive label distribution of query x i based on its distances to the N centers:

EQUATION

where h i is the representation of x i in the space:

EQUATION

)

The model is trained by minimizing Eq. 1 with p(y i |x i , S e ; θ) in Eq. 3. Through this training, in the representation space that we calculate h i and class centers, the inter-class distances are maximized and the intra-class distances are minimized. Therefore, training samples belonging to the same class are clustered together and clusters representing different classes are pushed apart.

3.1.3. INFERENCE AND THE TEST SAMPLE'S DISTANCE TO ITS GROUND-TRUTH CLASS CENTER:

At inference, we calculate the center of every class c using the training set, by averaging the representations of all corresponding training samples:

EQUATION

where T k is the set of all training samples belonging to class k. Then, given a test sample x t in the test set D test = {(x t , y t )} Ntest t=1 (where y t is the ground-truth label), the distances of its representation h t (Eq. 4) to all class centers are calculated. The prediction of the label of x t is based on these distances:

EQUATION

where M consists of all classes in the training set. In other words, x t is assigned to the class with the closest center in the representation space. Consequently, for a test sample (x t , y t ), if at inference h t is too far away from its ground-truth class center c test yt , it is likely to be mis-classified. Therefore, in this distance-based representation space, a test sample's distance to its ground-truth class center, is a strong signal indicating how well the model would perform on this sample. In the next section, we empirically show it under DBLE and compare with other methods. In the learned representation space (either the output space of a model from vanilla training or prototypical learning), for every sample (x t , y t ) in the test set D test = {(x t , y t )} Ntest t=1 , we calculate its L2-distance to its ground-truth class center c test yt as:

EQUATION

) where c test yt is given by Eq. 5. f θ is the trained classification model and d(, ) is L2-distance. We can also calculate x t 's distance to its predicted class center c test y t where y t is the predicted label, in both DBLE and vanilla training as comparison. We denote x t 's distance to its predicted class center as

d t = d(f θ (x t ), c test y t

). We then sort {d t } Ntest t=1 or {d t } Ntest t=1 in ascending order and partition them in I equally-spaced bins. For every bin, we calculate the model's classification accuracy of the test samples lying in the bin. Then, we plot the test accuracy curve as the distance increases. The curve shows the the relationship between the distance and the model's performance on x t , illustrating how well the calculated distance can act as confidence score, calibrating the model's prediction.

As shown in Fig. 2 , d t of DBLE, which is the distance of a test sample x t to its ground-truth class center, calibrates the model's performance the best. The curve of d t under DBLE's prototypical learning, despite its slight oscillation near 0 in the end, decreases monotonically to almost zero. It indicates that farther away the sample is from its ground-truth class center, more poorly the model performs on it. These results suggest that d t can be used as a gold confidence measure, calibrating the quality of the model's decision of x t for a classification model under prototypical learning. This benefit of DBLE's prototypical learning is due to the distance-based training and inference -if a test sample is farther away from its ground-truth class center, it is more likely to be mis-classified as other classes.

Although we have observed this gold calibration in DBLE enabled by prototypical learning, it requires access to the ground-truth labels of test samples, d t . At inference however, we do not have access to the ground-truth label of x t at inference and d t cannot be directly calculated. 

4. CONFIDENCE MODELING BY LEARNING FROM ERRORS:

In the classification model learned by DBLE, a test sample x t 's L2-distance d t to its ground-truth class center (Eq. 7), is highly-calibrated with the model's performance on it, as described in Sec. 3. However, d t cannot be directly computed without ground-truth labels, which is the case at inference. Therefore, we introduce a confidence model parameterized by φ, to learn to estimate d t jointly with the training of classification in DBLE.

To train φ, a straightforward option would be using the distances for all training samples, {(

x i , d i )} |T | i=1 .

Through this way, φ can be trained to give an estimate of d t for the test sample x t at inference. However, correctly-classified samples constitute the vast majority during training, especially considering that state-of-the-art DNNs yield much lower training errors compared to test errors (Neyshabur et al., 2014) . Therefore, if all data is used, training of g φ would be dominated by the small distances of the correctly-classified samples, which would make it harder for g φ to capture the larger d t for the minor mis-classified samples. Moreover, given that we choose g φ as a simple MLP with limited capacity for fast training, it becomes more challenging to capture larger d t from the incorrectly-classified samples if all training samples are used (i.e. the confidence model would underfit mis-classified training data). Therefore, we propose to track all training samples that are mis-classified in episode e during the training of the classification model. We save them in M e = {(x s , y s ), where y s = y s } for each episode e to train g φ . In our ablation studies in Sec. 5.4, we demonstrate the importance of learning from mis-classified training samples vs. learning from all.

Next, we introduce the training procedure of g φ with mis-classified samples for estimation of d t at inference for test sample t. We train g φ by sampling from the isotropic Gaussian distribution N (h s , diag(σ s σ s )), where the standard deviation σ s is g φ 's output given mis-classified training sample x s . g φ is trained to output a larger σ s for x s with a larger d s . g φ takes the representation h s (calculated with Eq. 4) of a mis-classified training sample x s in M e = {(x s , y s )} as input, and outputs σ s as,

EQUATION

To train g φ , we firstly sample another representation z s for x s from the isotropic Gaussian distribution parameterized by h s and σ s , z s ∼ N (h s , diag(σ s σ s )). Then, we optimize g φ based on the prototypical loss with z s , using z s 's predictive label distribution:

EQUATION

)

When updating φ with the prototypical loss given z s , it encourages a larger σ s when the d s of x s is larger. This is because when h s is fixed for x s in the space, maximizing Eq. 9 forces z s to be as close to its ground-truth class center as possible. Given z s is sampled from N (h s , diag(σ s σ s )), if h s is farther away from its ground-truth center (which is the case of mis-classified training samples), then it requires a larger σ s for z s to go close to it. Fig. 3 visualizes how σ changes before vs. after updating φ. The training of DBLE is described in Fig. 1 and in Algorithm 1 in the Appendix A.1. Note that in order to make sampling of z s differentiable, we use the reparameterization trick (Kingma & Welling, 2013).

At inference, for every test sample x t , we make prediction y t with h t (see Eq. 6). While for confidence estimation of the predictions, we take advantage of σ t . After getting h t and σ t , we sample multiple z u t from N (h t , diag(σ t σ t )) and average their predictive label distributions as confidence estimation:

EQUATION

)

U is the total number of representation samples z t . p(y t |x t ; φ) is used as the confidence score calibrating the prediction y t . Through this way, for a test sample farther away from its ground-truth class center (which means they are more likely to be mis-classified), the model will add more randomness to the representation sampling since its estimated variance from g φ is large. More randomness in the softmax input space leads to a lower expected softmax output (Gal & Ghahramani, 2016) , which is the confidence score p(y t |x t ; φ).

5. EXPERIMENTS:

In this section, we first compare DBLE to recent baselines on confidence calibration of DNNs.

We conduct experiments on a variety of data sets and network architectures and evaluate DBLE's performance on two most commonly used metrics for confidence calibration: Expected Calibration Error (ECE) (Naeini et al., 2015) and Negative Log Likelihood (NLL) (Friedman et al., 2001) . Results show that DBLE outperforms single-modal baselines on confidence calibration in every scenario tested. We then conduct ablation study to verify the effectiveness of the two main components of DBLE. Implementation, training details, and the details of the baselines are described in Appendix.

5.1. EXPERIMENTAL SETUP:

Baselines. We compare our method with 5 baselines that use a single DNN: vanilla training, MC-Dropout (Gal & Ghahramani, 2016) , Temperature Scaling (Guo et al., 2017) , Mixup (Thulasidasan et al., 2019) , Label Smoothing (Szegedy et al., 2016) and TrustScore (Jiang et al., 2018) . We also compare DBLE with Deep Ensemble (Lakshminarayanan et al., 2017) with 4 types of DNNs.

Datasets and Network Architectures. We conduct experiments on various combinations of datasets and architectures: MLP on MNIST (LeCun et al., 1998) , VGG-11 (Simonyan & Zisserman, 2014) on CIFAR-10 ( Krizhevsky et al., 2009) , ResNet-50 (He et al., 2016) on CIFAR-100 (Krizhevsky et al., 2009) and ResNet-50 on Tiny-ImageNet (Deng et al., 2009) .

Evaluation Metrics. We evaluate DBLE on model calibration with Expected Calibration Error (ECE) and Negative Log Likelihood (NLL). ECE approximates the expectation of the difference between accuracy and confidence. It partitions the confidence estimations (the likelihood of the predicted label p(y t |x t )) of all test samples into L equally-spaced bins and calculates the average confidence and accuracy of test samples lying in each bin I l :

EQUATION

where y t is the predicted label of x t . NLL averages the negative log-likelihood of all test samples: 

EQUATION

5.2. RESULTS:

Table 1 shows the results. In every scenario tested, DBLE is comparable with vanilla training in test accuracy -applying prototypical learning for classification problems does not hurt generalization of models on classification. On confidence calibration, DBLE performs all single-modal baselines on every scenario tested on both ECE and NLL. Moreover, our method reaches comparable results with Deep Ensemble of 4 networks with a smaller time complexity and parameter size. For MNIST-MLP, CIFAR10-VGG11 and CIFAR100-ResNet50, our method outperforms Deep ensemble (4 networks) on ECE. Among other baselines, Temperature Scaling performs the best in every scenario, which is because Temperature Scaling directly optimizes NLL on the small sub-training set. MC-dropout gives the least improvement on confidence calibration, especially on NLL. The potential reason for MC-dropout's limited improvement on NLL can be that when applying dropout at inference, it adds similar level of randomness on mis-classified samples and correctly classified samples. Therefore, the predictive likelihood of the correct labels becomes smaller in general, which leads to worse NLL. Compared to Temperature Scaling, DBLE decouples classification and calibration, therefore achieves better calibration without sacrificing classification performance. Compared to MC-dropout, our model is trained to add randomness on predictive distributions for mis-classified samples specifically, thus achieving significantly better calibration. Distance-based representation space and learning from errors are both essential for DBLE.

We conduct ablation studies to verify the effectiveness of the two main design choices of our model, the distance-based space and learning calibration from training errors. Table 2 shows the results.

In "Learning with errors in Vanilla training", we conduct calibration learning with errors in vanilla training. In other words, instead of updating φ by maximizing Eq. 9, we update φ by maximizing the softmax likelihood with z as logits and f θ is updated with vanilla training. In "DBLE with calibration learning using all samples", we update φ with all training samples by maximizing Eq. 9. We can see from the results that firstly, learning to calibrate with errors also helps vanilla training. It improves calibration in vanilla training slightly since it to some extent, introduces more randomness in the decision making process for misclassified samples. However, the improvement is very small without the distance-based space. decay are observed to affect confidence calibration (Guo et al., 2017) , we also keep them constant while comparing to baselines in every scenario. All models are trained with stochastic gradient descent with momentum (Sutskever et al., 2013) . We use an initial learning rate of 0.1 and a fixed momentum coefficient of 0.9 for all methods tested. The learning rate scheduling is tuned according to classification performance on validate set. All other hyperparameters of classification models for baselines are also chosen based on accuracy on validation set.

L(θ) ← 0 for c in C do for (x i , y i ) in Q c e do h i = f θ (x i ) L(θ) ← L(θ) + 1 N •K [d(h i , c yi ) + log k exp(-d(h i , c k ))]

M e = {} for c in C do for (x i , y i ) in Q c e do y i = argmin c {d(h i , c c )} N c=1 #hi = f θ (xi) if y t = y t then M e ← AddT o(x i , y i ) end if end for end for ### Compute confidence loss with mis-classified training samples for (x s , y s ) in M e do σ s = g φ (h s ) #hs = f θ (xs) ∼ N (0, 1) z s = h s + • σ s L(φ) ← L(φ) + 1 N •K [d(z s , c ys ) + log k exp(-d(z s , c k ))]

There are several unique hyper-parameters in DBLE. We describe how we choose them in the following paragraph. In DBLE, we stop the training when the classification model converges. The confidence model g φ is a two-layer MLP with Dropout (Srivastava et al., 2014) added in between. we use ReLU non-linearity (Glorot et al., 2011) for the MLP. We fix the dropout rate as 0.5. The N (number of classes), K (number of shots) and the batch-size of the query set for every episode in DBLE's are firstly tuned according to the classification performance on validation set to reach comparable performance with vanilla training. Then the N , K and the batch-size of the query set for every episode are fine-tuned according to the DBLE's calibration performance on validation set. At inference, we fix the number of representation sampling U in Eq. 10 as 20. This is because we empirically observed that a U larger than 20 doesn't give performance improvements. We set the number of bins L in Eq. 11 as 15 following (Guo et al., 2017) .

A.3 TRAINING THE CONFIDENCE WITH ALL TRAINING SAMPLES VS. WITH MIS-CLASSIFIED TRAINING SAMPLES:

In addition to the final results we report in the ablation study (the last two rows of Table 2 ) comparing training the confidence with all training samples vs. with mis-classified training samples, we also checked statistics of σ, which is the standard deviation predicted by the confidence model. For CIFAR-10, the mean of σ of the model trained with all samples is 0.203, while that of the model trained with mis-classified training samples is 0.740. This suggests that if we train the confidence model with all training samples, the model outputs for test samples are indeed smaller in general, which is aligned with our intuition. The histogram of σ under these two methods are shown in Figure 5 .

:

Note that we do not require N to be equal to M because fitting the support samples of all M classes in a batch to processor memory can be challenging when M is very large.

Figures and Tables:

Figure 2: Average test accuracy as d t or d t increases. d t is the distance of a test sample x t to its ground-truth class center and d t is its distance to the predicted class center. It shows that d t in the space achieved by prototypical learning in DBLE can better estimate the model's performance on x t , since DBLE's accuracy curve is more monotonic and less oscillating as the distance increases.

Therefore, we propose to use a separate confidence model to estimate d t , trained jointly with the classification training of DBLE. It regresses d t by learning from the mis-classified training samples in DBLE's classification training, described next.

Figure 3: The Gaussian distribution within one standard deviation σ away from mean, shown before and after updating φ. The dotted circles represent the σ of the sample inside it. Red and blue dots represent training samples belonging two different classes in the representation space. The dotted line is the decision boundary in the space. Let's take the two mis-classified training samples h a , h b and the correctly classified h c as examples. (a), before updating φ, the σs of both correctly and wrongly located samples are initialized with a small value. (b), after updating φ, σ of mis-classified samples are much larger. Because the proto-loss for calibration will move z, sampled from N (h, diag(σ σ)), to be as close to the correct class center as possible.

Figure 4: Test ECE and NLL of the last 45 epochs during training on CIFAR-100. The learning rate of both vanilla training and DBLE is annealed by 10x at epoch 60, 70, 80.

OF ONE UPDATE OF DBLEAlgorithm 1: One update of DBLE. M is the total number of classes in the training set, N is the number of classes in every episode, K is the number of supports for each class, K Q is the number of queries for each class.Input:Training set D train = {(x i , y i )} i , y i ∈ {1, ..., M }. D c train = {(x i , y i ) ∈ D train | y i = c}. # Buildtraining episode e ## Select N classes for episode e C ← RandomSample({1, ..., M }, N ) ## Sample supports and queries for every class in e for c in C do S c e ← RandomSample(D c train , K) Q c e ← RandomSample(D c train \ S c e , K Q ) end for # Compute Loss ## Compute center representation for every class c in e for c in C do c c ← 1 |S c e | (sj ,yj )∈S c e f θ (s j ) end for ## Compute prototypical loss for classification

Make predictions and track mis-classified training samples

end for # Update θ with prototypical loss for classificationθ ← θ -r • L(θ) # Update φ with confidence loss φ ← φ -r • L(φ)A.2 IMPLEMENTATION AND TRAINING DETAILS OF DBLE AND BASELINESFor a fair comparison with baseline methods, in every scenario tested, the network architecture is identical for DBLE and all other baselines. As regularization techniques such as BatchNorm, weight

Figure 5: The histogram of σ of models trained with all training samples vs. with mis-classified training samples on CIFAR-10.

N ×K j=1 containing K examples for each of the N classes and (ii) the query set Q e = {(x i , y i )} Q i=1 containing different examples from the same N classes.

Table content: <table><tr><td/><td/><td>Qe</td><td/><td/></tr><tr><td>L(θ) = E (Se,Qe)</td><td>-</td><td>i=1</td><td colspan="3">log p(yi|xi, Se; θ).</td><td>(1)</td></tr><tr><td/><td/><td/><td colspan="3">Classification Model</td><td>Confidence Model</td><td>Proto-loss for calibration</td></tr><tr><td/><td/><td colspan="2">x i Query Sample Support Set S e</td><td>f θ</td><td>μ i h i</td><td>g ɸ σ i {p 1 , p 2 ,…, p N } Sampling Operation {c 1 , c 2 ,… , c N }</td><td>z i</td></tr><tr><td/><td/><td/><td/><td/><td>Proto-loss for classification</td></tr><tr><td/><td/><td colspan="4">Figure 1: The training of DBLE. Taking support set</td></tr><tr><td/><td/><td colspan="4">S e and a query image x i as input, f θ learns a repre-</td></tr><tr><td/><td/><td colspan="4">sentation space through the training of classification</td></tr><tr><td/><td/><td colspan="4">model. In this space, h i is the encoded query inputs</td></tr><tr><td/><td/><td colspan="4">and {c 1 , ..., c N } are the class centers. For classifi-</td></tr><tr><td/><td/><td colspan="4">cation, DBLE employs proto-loss to update f θ . For</td></tr><tr><td/><td/><td colspan="4">calibration, DBLE employs the centers and the sam-</td></tr><tr><td/><td/><td colspan="4">pled representation z</td></tr></table>

Test Accuracy, ECE and NLL of DBLE and baselines under 4 scenarios.

Table content: <table><tr><td>Method</td><td colspan="2">MNIST-MLP</td><td/><td colspan="2">CIFAR10-VGG11</td><td/></tr><tr><td/><td>Accuracy%</td><td>ECE%</td><td>NLL</td><td>Accuracy%</td><td>ECE%</td><td>NLL</td></tr><tr><td>Vanilla Training</td><td>98.32</td><td>1.73</td><td>0.29</td><td>90.48</td><td>6.3</td><td>0.43</td></tr><tr><td>MC-Dropout</td><td>98.32</td><td>1.71</td><td>0.34</td><td>90.48</td><td>3.9</td><td>0.47</td></tr><tr><td>Temperature Scaling</td><td>95.14</td><td>1.32</td><td>0.17</td><td>89.83</td><td>3.1</td><td>0.33</td></tr><tr><td>Label Smoothing</td><td>98.77</td><td>1.68</td><td>0.30</td><td>90.71</td><td>2.7</td><td>0.38</td></tr><tr><td>Mixup</td><td>98.83</td><td>1.74</td><td>0.24</td><td>90.59</td><td>3.3</td><td>0.37</td></tr><tr><td>TrustScore</td><td>98.32</td><td>2.14</td><td>0.26</td><td>90.48</td><td>5.3</td><td>0.40</td></tr><tr><td>DBLE</td><td>98.69</td><td>0.97</td><td>0.12</td><td>90.92</td><td>1.5</td><td>0.29</td></tr><tr><td>Deep Ensemble-4 networks</td><td>99.36</td><td>0.99</td><td>0.08</td><td>92.4</td><td>1.8</td><td>0.26</td></tr><tr><td>Method</td><td colspan="2">CIFAR100-ResNet50</td><td/><td colspan="3">Tiny-ImageNet-ResNet50</td></tr><tr><td/><td>Accuracy%</td><td>ECE%</td><td>NLL</td><td>Accuracy%</td><td>ECE%</td><td>NLL</td></tr><tr><td>Vanilla Training</td><td>71.57</td><td>19.1</td><td>1.58</td><td>46.71</td><td>25.2</td><td>2.95</td></tr><tr><td>MC-Dropout</td><td>71.57</td><td>9.7</td><td>1.48</td><td>46.72</td><td>17.4</td><td>3.17</td></tr><tr><td>Temperature Scaling</td><td>69.84</td><td>2.5</td><td>1.23</td><td>45.03</td><td>4.8</td><td>2.59</td></tr><tr><td>Label Smoothing</td><td>71.92</td><td>3.3</td><td>1.39</td><td>47.19</td><td>5.6</td><td>2.93</td></tr><tr><td>Mixup</td><td>71.85</td><td>2.9</td><td>1.44</td><td>46.89</td><td>6.8</td><td>2.66</td></tr><tr><td>TrustScore</td><td>71.57</td><td>10.9</td><td>1.43</td><td>46.71</td><td>19.2</td><td>2.75</td></tr><tr><td>DBLE</td><td>71.03</td><td>1.1</td><td>1.09</td><td>46.45</td><td>3.6</td><td>2.38</td></tr><tr><td>Deep Ensemble-4 networks</td><td>73.58</td><td>1.3</td><td>0.82</td><td>51.28</td><td>2.4</td><td>1.81</td></tr></table>

5.3 COMPUTATIONAL COST DBLE adds extra training time complexity and trainable parameters compared with vanilla training. However, compared with Deep Ensembles and other Bayesian methods, DBLE's cost is significantly less. For training time complexity, although DBLE requires two forwards passes for f θ at each update step (see Algorithm 1), its actual training time is less than twice of vanilla training since the number of iterations required until convergence is smaller. Empirically we observe that DBLE's total training time on CIFAR10-VGG11 is 1.4x of vanilla training and on CIFAR100-ResNet50 is 1.7x of vanilla training. While Deep Ensemble of 4 networks takes 4x vanilla training time. DBLE adds extra trainable parameters φ compared with vanilla training. φ is the parameters of a MLP in practice. It's size is usually 1% -3% of the classification model, while ensembling 4 DNNs in Deep Ensemble increases the size of trainable parameters to 4x of vanilla training.

Table content: <table/>

Ablation study on CIFAR-100 and Tiny-ImageNet 5.4 ALGORITHM ANALYSIS AND ABLATION STUDY DBLE alleviates the NLL overfitting problem. NLL overfitting problem of vanilla training has been observed in(Guo et al., 2017) -after annealing the learning rate, as the test accuracy goes up, the model overfits to NLL score (test NLL starts to increase instead of decreasing or maintaining flat). Fig.4shows that this phenomenon is alleviated by DBLE. Under vanilla training, the model starts overfitting to NLL after the first learning rate annealing. DBLE on the other hand, decreases and maintains its test NLL every time after learning rate annealing. We see the same trend for test ECE as well -with vanilla training the model overfits to ECE after learning rate annealing while DBLE decreases and maintains its test ECE.

Table content: <table/>

Secondly, we notice that in DBLE if we learn calibration with all training samples, it significantly decreases DBLE's performance on calibration. The potential reason is the model's underfitting to mis-classified training samples in learning to estimate the distance. Auxiliary analysis on these two can be found in Appendix A.3.

Table content: <table><tr><td>6 CONCLUSION</td></tr></table>

Peer review (iclr2020):
Summary: The paper proposes a method to do confidence calibration for deep neural networks. It uses standard episodic training for prototypical networks, and first shows empirically that the distances of the embedded test point to its ground truth class center embedding (*not* the predicted class embedding) are indicative of the confidence of the prediction. Further it proposes to exploit this by training an auxiliary confidence prediction MLP carefully. To do so they demonstrate that the training needs to be done of erroneously predicted training examples cf. all the traning examples. They show results with MLP+MNIST, VGG11+CIFAR10, ResNet50+CIFAR100 and ResNet50+TinyImageNet. Detailed comments: The paper is interesting but largely empirical. It shows empirically that: 1. when prototypical networks (and episodic training) is used the distance of test example to true class center reflects the confidence. 2. this does not hold when `vanilla* training is used 3. an auxiliary MLP can be used to learn to predict this while training only with erroneously classified training examples cf. all training examples The results are reported on three networks (MLP, VGG11 and ResNet50) on different benchmarks of image classification. The confidence prediction improvements wrt baselines are non trivial, while keeping the accuracy similar, and the computation cost lower than competing methods. Ablations studies are also convincing. I would have two broad critical comments on the paper: 1. Would this generalize to other image classification tasks and datasets. Generally distance (embedding) based networks perform less than softmax based networks on bigger datasets, so an immediate disadvantage if that happens, is that you would be trading off accuracy cf. vanilla networks, for better confidence prediction using the required distance based network here. 2. The vanilla training is never formally detailed. I am assuming it was softmax + cross entropy loss with gradient descent. Would some other loss be helpful? Specially the metric learning based losses like contrastive or triplet losses come to mind, since they are also distance based. Does the method work with prototypical networks only or it generalizes to other distance based methods as well? Minor comments: The notations are a bit confusing sometimes, and require going back and forth a bit. Eg. mu is used for representation of feature (Eq4) while it usually denotes a mean of some sort (so the reader*s expectation could be that it represents class center). Similarly, boldface p is used for class centers, which is again a bit confusing as being a probability of some sort. In general the notations are different from the original prototypical networks paper (which I needed to revise); keeping them similar would help the reader. The contribution of the present paper is more than that anyway. The erroneously classified training examples are called errors (eg. just before eq8). By errors one could think that it is a difference between some sort of prediction and the ground truth. Explicitly calling them erroneously classified training examples would help the reader as well. The notation odot is not explained (before eq.9).