Source-linked AI summary

On Calibration of Modern Neural Networks

Chuan Guo, Geoff Pleiss, Yu Sun, Kilian Q. Weinberger

arXiv:1706.04599v2cs.LG

TL;DR

Modern neural networks can produce confidence estimates that do not reflect true correctness probabilities, despite improved classification accuracy. The paper evaluates calibration across architectures and tasks and finds that temperature scaling is often the most effective remedy.

  • Problem

    Modern neural networks produce confidence estimates that may not represent true correctness probabilities, although calibrated estimates matter for trust and probabilistic modeling.

  • Method

    The paper evaluates neural-network calibration across vision and NLP tasks, examines architectural and training factors, and compares post-processing calibration methods.

  • Results

    Temperature scaling is often the most effective calibration method, outperforming alternatives on vision tasks and performing comparably on NLP datasets.

  • Takeaways & Limitations

    Simple temperature scaling provides a practical, fast, and straightforward way to remedy miscalibration in modern neural networks.

  • Takeaways & Limitations

    Matrix scaling performs poorly on datasets with hundreds of classes and fails to converge on ImageNet, where its parameter count can cause overfitting.

Abstract

from arXiv · show

Confidence calibration -- the problem of predicting probability estimates representative of the true correctness likelihood -- is important for classification models in many applications. We discover that modern neural networks, unlike those from a decade ago, are poorly calibrated. Through extensive experiments, we observe that depth, width, weight decay, and Batch Normalization are important factors influencing calibration. We evaluate the performance of various post-processing calibration methods on state-of-the-art architectures with image and document classification datasets. Our analysis and experiments not only offer insights into neural network learning, but also provide a simple and straightforward recipe for practical settings: on most datasets, temperature scaling -- a single-parameter variant of Platt Scaling -- is surprisingly effective at calibrating predictions.

1. Introduction

Modern neural networks are increasingly used in consequential decision-making systems, where accuracy alone is insufficient: models must also provide confidence estimates that reflect when predictions may be wrong. The paper shows that, despite improved accuracy, modern networks are no longer well-calibrated and studies why and how to alleviate this problem.

  • Motivation: Neural networks deployed in complex applications must indicate when they are likely to be incorrect, not merely classify accurately.This supports fallback to other sensors or human experts when model confidence is low.
  • Motivation: Calibrated confidence estimates can improve interpretability and establish user trust in otherwise difficult-to-interpret neural-network decisions.Probability estimates can also provide additional information when combining network outputs with other systems.
  • Problem: Modern neural networks are no longer well-calibrated, despite being more accurate than neural networks a decade ago.The paper contrasts a 5-layer LeNet with a 110-layer ResNet on CIFAR-100.
  • Contributions: The paper investigates why neural networks have become miscalibrated and identifies methods that can alleviate the problem.It studies computer vision and NLP tasks, examines training and architectural trends, and compares post-processing calibration methods.

2. Definitions

The section defines confidence calibration for supervised multiclass neural-network classification and introduces empirical tools for assessing it. These tools include reliability diagrams, ECE, MCE, and NLL, each capturing probabilistic prediction quality in a different way.

  • Calibration: A neural network is calibrated when its confidence estimate represents the true probability that its predicted class is correct.Perfect calibration is defined over the joint data distribution, but cannot be achieved or computed exactly from finite samples.
  • Reliability Diagrams: Reliability diagrams plot expected sample accuracy against confidence, with perfect calibration represented by the identity function.Finite-sample estimates group predictions into confidence bins; a calibrated model has equal bin accuracy and average confidence in every bin.
  • Expected Calibration Error: Expected Calibration Error summarizes calibration as a weighted average of the absolute accuracy–confidence gaps across equally spaced bins.The paper uses ECE as its primary empirical metric for measuring calibration.
  • Maximum Calibration Error: MCE measures the largest calibration gap across bins, whereas ECE is a weighted average of all gaps.For perfectly calibrated classifiers, both MCE and ECE equal 0.
  • Negative Log Likelihood: Negative log likelihood, also called cross entropy loss in deep learning, evaluates probabilistic model quality and is minimized in expectation exactly when the predicted conditional distribution matches the ground truth.This makes NLL a measure of probabilistic prediction quality rather than a bin-based calibration summary.

3. Observing Miscalibration

Modern neural networks become miscalibrated as capacity increases and regularization decreases, although these factors are observationally related rather than proven causal. Batch Normalization and training dynamics also contribute, with calibration diverging from classification accuracy and NLL revealing probabilistic overfitting.

  • Interpretation: The observed relationship between miscalibration, increased capacity, and reduced regularization is associative rather than established as causal.The paper connects probabilistic overfitting in high-capacity models to the disconnect between NLL and 0/1 loss.
  • Model capacity: Increased depth and width reduce classification error but negatively affect calibration in ResNets trained on CIFAR-100.Figure 2 evaluates error and ECE while varying depth and convolutional filters per layer.
  • Batch Normalization: Models trained with Batch Normalization tend to be more miscalibrated, despite slightly improved classification accuracy in a 6-layer ConvNet.The observation holds across the Batch Normalization hyperparameters discussed in the passage.
  • Weight decay: Less weight decay negatively impacts calibration, and calibration and accuracy are not optimized by the same parameter setting.For a 110-layer ResNet, calibration does not appear negatively affected by too much weight decay, even when classification error indicates over-regularization.
  • Training dynamics: NLL and accuracy can diverge because neural networks may overfit NLL without overfitting the 0/1 loss.Training curves for some miscalibrated models show this disconnect, with both test error and NLL dropping at epoch 250.

4. Calibration Methods

Calibration methods are post-processing procedures trained on a hold-out validation set under a shared-distribution assumption. The section reviews non-parametric and parametric approaches for binary and multiclass classification, including temperature scaling as a single-parameter extension of Platt scaling that preserves accuracy.

  • General setup: All calibration methods are post-processing steps that produce calibrated probabilities using a hold-out validation set, with training, validation, and test data assumed identically distributed.The validation set may also serve for hyperparameter tuning.
  • Binary calibration: Histogram binning assigns each prediction to a bin and replaces it with that bin’s calibrated score, while isotonic regression jointly optimizes piecewise-constant bin boundaries and predictions.Isotonic regression minimizes square loss and strictly generalizes histogram binning.
  • Binary calibration: Bayesian Binning into Quantiles extends histogram binning by marginalizing over possible binning schemes through Bayesian model averaging.Histogram binning and isotonic regression select a single scheme, whereas BBQ considers a space of possible schemes.
  • Binary calibration: Platt scaling fits logistic-regression parameters a and b on validation logits and outputs calibrated probabilities as σ(azi + b).It is a parametric method, unlike the other binary approaches reviewed here.
  • Multiclass calibration: For multiclass calibration, binning methods can be extended through K one-versus-all calibration models, while matrix and vector scaling transform logits with class-dependent parameters.Vector scaling restricts the matrix in matrix scaling to be diagonal, reducing parameter growth from quadratic dependence on K.
  • Multiclass calibration: Temperature scaling uses one scalar T > 0 for all classes, is optimized by validation NLL, leaves the class prediction unchanged, and therefore does not affect accuracy.T > 1 softens the softmax by increasing output entropy, while T = 1 recovers the original probabilities.

5. Results

Across image and document classification experiments, modern neural networks were often miscalibrated, while simple calibration methods—especially temperature scaling—were effective. More complex methods faced accuracy, convergence, overfitting, or computational disadvantages.

  • Calibration Results: Most datasets and models showed miscalibration, with ECE typically between 4% and 10% across convolutional, recurrent, and deep averaging networks.ECE was measured with M = 15 bins.
  • Calibration Results: Temperature scaling outperformed all other methods on vision tasks and performed comparably to other methods on NLP datasets.It also outperformed the more general vector and matrix Platt scaling variants.
  • Calibration Results: Reuters was the only dataset that temperature scaling did not calibrate; its initial ECE was ≤1%, leaving little room for improvement.The passage notes that split choice or binning could have affected the measurements.
  • Calibration Results: Matrix scaling performed poorly on Birds, Cars, and CIFAR-100 and failed to converge on 1000-class ImageNet.Its parameter count scales quadratically with the number of classes, increasing overfitting risk on small validation sets.
  • Calibration Results: Binning methods improved calibration on most datasets but did not outperform temperature scaling, and they tended to change class predictions and hurt accuracy.Histogram binning typically outperformed isotonic regression and BBQ despite being less general.
  • Computation time: Temperature scaling was the fastest method: conjugate gradient found the optimal temperature in 10 iterations, while BBQ took roughly 3 orders of magnitude more time.All methods scaled linearly with validation-set size; vector and matrix scaling were linear and quadratic in the number of classes, respectively.

6. Conclusion

Modern neural networks can become less calibrated even as their classification error improves. Architecture and training choices strongly affect calibration, while simple techniques can effectively remedy miscalibration.

  • Probabilistic error and miscalibration worsen even as classification error is reduced.
  • Model capacity, normalization, and regularization strongly affect network calibration.
  • Simple techniques can effectively remedy the miscalibration phenomenon.

Supplementary Materials for: On Calibration of Modern Neural Networks · S1. Further Information on Calibration Metrics

This subsection connects Expected Calibration Error (ECE) to the paper’s exact definition of miscalibration. It expresses the relationship using cumulative-distribution and Riemann–Stieltjes formulations, with finite-bin ECE converging to a corresponding Riemann–Stieltjes sum.

  • S1. Further Information on Calibration Metrics: ECE is connected to the paper’s exact miscalibration definition.The definition is explicitly restated before establishing the connection.
  • S1. Further Information on Calibration Metrics: The cumulative distribution function F_ˆP describes the distribution of predicted probabilities ˆP.It satisfies F_ˆP(b) − F_ˆP(a) = P(ˆP ∈ [a, b]).
  • S1. Further Information on Calibration Metrics: The probability-mass difference over an interval is represented as P(ˆP ∈ [a, b]).This identity defines the increment of the cumulative distribution function used in the derivation.
  • S1. Further Information on Calibration Metrics: The derivation applies a Riemann–Stieltjes integral to the predicted-probability distribution.The integral formulation uses the cumulative distribution function of ˆP.
  • S1. Further Information on Calibration Metrics: For bin B_m, I_m denotes its interval, and the conditional calibration term is P(ˆY = Y | ˆP = p_m) − p_m.This term compares correctness likelihood with the representative predicted probability p_m.
  • S1. Further Information on Calibration Metrics: For large n, the bin-level discrepancy is represented by |acc(B_m) − ˆp(B_m)|.The passage relates the conditional calibration expression to the empirical bin discrepancy.
  • S1. Further Information on Calibration Metrics: ECE with M bins converges to the M-term Riemann–Stieltjes sum.The convergence is stated for n large and follows the bin-based discrepancy formulation.

S2. Further Information on Temperature Scaling

This section derives temperature scaling as the unique entropy-maximizing solution under balanced constraints and shows how it addresses over-confidence caused by low-entropy predictions. As training continues, temperature scaling lowers NLL while increasing predictive entropy.

  • Entropy-maximization derivation: Temperature scaling is derived as the unique solution to an entropy maximization problem over class-probability distributions subject to balanced constraints.The derivation uses an entropy maximization principle with an appropriate balanced equation.
  • Entropy-maximization derivation: The constraints ensure valid probability distributions and require the average true-class logit to equal the average weighted logit.The first two constraints define a probability distribution, while the final constraint limits the distribution scope.
  • Entropy-maximization derivation: The Lagrangian optimization recovers the temperature scaling model by setting T = 1.The proof differentiates with respect to q(zi)(k), sets the Lagrangian gradient to 0, and rearranges the result.
  • Training dynamics: As training continues, overfitting with respect to NLL produces a low-entropy softmax distribution that explains model over-confidence.Figure S1 represents NLL with a red line and softmax entropy with a blue line.
  • Training dynamics: Temperature scaling lowers NLL and raises the entropy of the predictive distribution.Figure S1 visualizes this effect with the NLL shown in red and entropy shown in green.

S3. Additional Tables

The supplementary tables report MCE, test error, and NLL across the experimental settings, while supplementary analyses examine calibration’s effects on entropy and NLL. They also note that MCE is sensitive to binning and less suitable for small test sets.

  • Supplementary tables: Tables S1–S3 report MCE, test error, and NLL for all experimental settings from Section 5.These tables cover the reported settings before and after calibration.
  • Entropy and NLL: The optimal T selected by temperature scaling rises during optimization as pre-calibration entropy steadily decreases.For CIFAR-100, post-calibration validation entropy and NLL coincide through the gradient optimality condition of T.
  • MCE: MCE is highly sensitive to the binning scheme and is less suited for small test sets.Table S1 reports MCE (%) with M = 15 bins across standard vision and NLP datasets and calibration methods.

S4. Additional Reliability Diagrams

This section provides additional reliability diagrams for CIFAR-10 and SST datasets, showing predictions before and after calibration. The diagrams should not be interpreted as showing the proportion of predictions in each bin.

  • Additional reliability diagrams: Additional reliability diagrams are provided for CIFAR-10 and SST datasets.CIFAR-10 appears in Figure S2, while SST appears in Figures S3 and S4.
  • Interpretation: Reliability diagrams do not represent the proportion of predictions belonging to a given bin.This limitation is noted explicitly in connection with the diagrams.
  • CIFAR-10: Figure S2 shows CIFAR-10 reliability diagrams before and after calibration.The figure presents uncalibrated predictions alongside three post-calibration views.
  • SST: Figures S3 and S4 show SST Binary and SST Fine Grained reliability diagrams before and after calibration.Both figures present the datasets before calibration and across three post-calibration views.
Loading 1706.04599v2…