Scalable computation of prediction intervals for neural networks via matrix sketching

Alexander Fishkov, Maxim Panov

TL;DR

This paper introduces "Important Directions," a scalable algorithm for generating prediction intervals for pre-trained neural networks without requiring retraining or architectural changes. By combining the classical statistical delta method with efficient matrix sketching, the authors achieve uncertainty estimates that rival deep ensembles at a fraction of the computational cost.

What Problem Does This Paper Address?

While modern neural networks are powerful predictors, they are notoriously bad at quantifying their own uncertainty. Knowing when a model is likely to be wrong is critical in high-stakes fields like medicine or autonomous driving.

Current solutions have significant drawbacks:

  • Bayesian Neural Networks are theoretically sound but often computationally intractable for large models.
  • Deep Ensembles provide high-quality uncertainty estimates but require training and running multiple models, which is expensive.
  • The Delta Method, a classical statistical approach, uses a linear approximation of the model to estimate intervals. However, it requires computing and inverting a parameter covariance matrix based on the Jacobian. For a network with $m$ parameters and $n$ data points, this involves $O(nm^2 + m^3)$ complexity—impossible for modern networks with millions of parameters.

The authors aim to make the delta method practical for deep learning by drastically reducing its computational and memory footprint.

Methods

The core innovation is the Important Directions algorithm, which uses matrix sketching to approximate the massive Jacobian matrix ($J$).

  1. Linearization: The method starts with the "delta method," which treats the neural network as a linear function of its weights near the optimal solution.
  2. Matrix Sketching (RFD): Instead of storing the full Jacobian, the authors use a modified version of Robust Frequent Directions (RFD). This is an "online" algorithm that processes training data row-by-row (one gradient at a time), maintaining a low-rank approximation of the matrix.
  3. The Scoring Function: Standard sketching techniques keep the largest singular values of the Jacobian. However, the authors realized that for uncertainty estimation, the most important directions for the inverse covariance matrix ($\Sigma^{-1}$) are not necessarily the largest singular values of $J$. They introduce a specific scoring function (Equation 6) to select the "important directions" that most influence the final prediction interval.
  4. SVD Simplification: By using a truncated Singular Value Decomposition (SVD), they derive efficient formulas for the prediction interval and the "effective number of parameters" ($p^*$), avoiding the need for expensive matrix inversions.

Datasets

The authors evaluated their method on 11 regression datasets from the UCI Machine Learning Repository:

  • Ailerons, Boston, CT, Concrete, Energy, Protein, SGEMM, Superconduct, Wine, Yacht, and Year.

These range from small-scale (Boston) to relatively large-scale (Year Prediction MSD) datasets, providing a broad benchmark for regression performance.

Key Insights and Ideas

  • Don't Just Follow the Gradients: The most surprising insight is that the "largest" directions in the Jacobian aren't always the most informative for uncertainty. As shown in Figure 1, their method specifically targets the part of the spectrum that matters for the covariance matrix.
Fig. 1. Approximation quality of Important Directions (rank k = 200) for a [50, 50] fully-connected network trained on the Wine Quality dataset. Dotted lines show the true specters of the matrices and solid lines show their respective approximations, shifted horizontally for visual clarity.
  • Post-Hoc Applicability: Unlike ensembles or dropout, this method can be applied to a model that has already been trained. This makes it a powerful tool for practitioners who want to add uncertainty estimates to existing production models.
  • Efficiency via Online Processing: Because the algorithm is online, it never needs to hold the entire dataset or the full Jacobian in memory. Its space complexity is only $O(km)$, where $k$ is the chosen rank (e.g., 500) and $m$ is the number of parameters.

Key Results

  • Speedup: On the "CT" dataset, the Important Directions method was 100x faster than the exact delta method (24 seconds vs. 2398 seconds) while maintaining nearly identical performance.
  • Competitive Accuracy: In head-to-head comparisons (Table 2), Important Directions achieved coverage probabilities ($p_{cov}$) very close to the nominal 95% target, performing on par with Deep Ensembles and significantly outperforming MC-Dropout.
  • Error Correlation: The width of the intervals produced by this method showed a higher correlation with the actual prediction error ($r$) compared to other methods, meaning the intervals are "honest" about when the model is struggling.

Limitations and Future Work

  • Memory Constraints: While scalable, the method still requires storing $k$ vectors of size $m$. For models with hundreds of millions of parameters, even a rank of $k=500$ might exceed GPU memory. The authors suggest potentially applying the method only to the "top layers" of a network to mitigate this.
  • Classification: The current work focuses on regression. While the authors suggest a "one-vs-rest" approach for classification, a native extension to categorical outputs remains a topic for future research.
  • Hyperparameter Tuning: The choice of rank $k$ is a trade-off between accuracy and memory, though the authors note diminishing returns as $k$ increases.

Summary updated

Abstract

Accounting for the uncertainty in the predictions of modern neural networks is a challenging and important task in many domains. Existing algorithms for uncertainty estimation require modifying the model architecture and training procedure (e.g., Bayesian neural networks) or dramatically increase the computational cost of predictions such as approaches based on ensembling. This work proposes a new algorithm that can be applied to a given trained neural network and produces approximate prediction intervals. The method is based on the classical delta method in statistics but achieves computational efficiency by using matrix sketching to approximate the Jacobian matrix. The resulting algorithm is competitive with state-of-the-art approaches for constructing predictive intervals on various regression datasets from the UCI repository.
BibTeX
@inproceedings{fishkov2021scalable,
  author = {Alexander Fishkov and Maxim Panov},
  title = {{Scalable computation of prediction intervals for neural networks via matrix sketching}},
  booktitle = {AIST},
  year = {2021},
  url = {https://openreview.net/forum?id=3tqdMj0h3ZI},
}
Figure