Verifying Probabilistic Specifications with Functional Lagrangians

Leonard Berrada, Sumanth Dathathri, Krishnamurthy Dvijotham, Robert Stanforth, Rudy Bunel, Jonathan Uesato, Sven Gowal, M. Pawan Kumar

Abstract

Most real world applications require dealing with stochasticity like sensor noise or predictive uncertainty, where formal specifications of desired behavior are inherently probabilistic. Despite the promise of formal verification in ensuring the reliability of neural networks, progress in the direction of probabilistic specifications has been limited. In this direction, we first introduce a general formulation of probabilistic specifications for neural networks, which captures both probabilistic networks (e.g., Bayesian neural networks, MC-Dropout networks) and uncertain inputs (distributions over inputs arising from sensor noise or other perturbations). We then propose a general technique to verify such specifications by generalizing the notion of Lagrangian duality, replacing standard Lagrangian multipliers with "functional multipliers" that can be arbitrary functions of the activations at a given layer. We show that an optimal choice of functional multipliers leads to exact verification (i.e., sound and complete verification), and for specific forms of multipliers, we develop tractable practical verification algorithms. We empirically validate our algorithms by applying them to Bayesian Neural Networks (BNNs) and MC Dropout Networks, and certifying properties such as adversarial robustness and robust detection of out-of-distribution (OOD) data. On these tasks we are able to provide significantly stronger guarantees when compared to prior work -- for instance, for a VGG-64 MC-Dropout CNN trained on CIFAR-10, we improve the certified AUC (a verified lower bound on the true AUC) for robust OOD detection (on CIFAR-100) from $0\% \rightarrow 29\%$. Similarly, for a BNN trained on MNIST, we improve on the robust accuracy from $60.2\% \rightarrow 74.6\%$. Further, on a novel specification -- distributionally robust OOD detection -- we improve the certified AUC from $5\% \rightarrow 23\%$.

Introduction

Formal verification serves as the "gold standard" for ensuring the safety and reliability of neural networks. However, traditional verification tools are predominantly designed for deterministic settings, where constraints are defined by rigid bounds (e.g., "if the input is within this box, the output must be class X"). In real-world scenarios, uncertainty is ubiquitous—sensors exhibit noise, and robust AI systems often utilize stochastic components like Bayesian Neural Networks (BNNs) or Monte-Carlo (MC) Dropout to quantify uncertainty.

There is a critical need to verify probabilistic properties, such as ensuring the probability of misclassification under sensor noise remains below a specific threshold. Prior attempts to address this have often been limited to narrow use cases or have yielded "vacuous" (useless) guarantees. This work introduces a unified, scalable framework to verify complex, distribution-based properties in neural networks.

The Functional Lagrangian Framework

The core innovation of this research is the Functional Lagrangian Framework. In standard optimization, Lagrangian multipliers are typically scalars used to convert constraints into penalties. However, for probabilistic constraints involving entire distributions, linear multipliers lack the necessary expressivity.

Functional Multipliers

The proposed method replaces standard multipliers with functions $\lambda(x)$ of the activations at each layer. This allows the penalty to vary dynamically based on where the distribution lies within the activation space. The authors prove that this approach is inherently sound (providing a valid upper bound on violations) and theoretically complete (capable of finding the exact maximum violation with optimal function selection).

Tractable Implementation

To make the optimization over arbitrary functions feasible, the framework identifies specific classes of multipliers—such as linear-exponential or quadratic—that result in solvable sub-problems. Gradient-based optimization is employed to find optimal multipliers, and the framework leverages layer-wise decomposition to break down global verification into parallelizable sub-problems. Notably, this method is verification-agnostic and can be applied to "off-the-shelf" models without requiring specialized training.

Experimental Evaluation

The framework was evaluated across several benchmarks, including MNIST for BNNs and CIFAR-10 for MC-Dropout VGG networks. Out-of-distribution (OOD) detection was tested using EMNIST and CIFAR-100.

Comparison of GAUC and computation time between BP and FL methods.

As shown in the table above, the Functional Lagrangian (FL) method provides a substantial improvement in Guaranteed AUC (GAUC)—a verified lower bound on a model's OOD detection capability—compared to the standard Bound Propagation (BP) baseline. For instance, on a VGG-64 model trained on CIFAR-10, the GAUC improved from a vacuous 0.0% to 29.5%.

Key Results

  • Robust OOD Detection: For a VGG-64 model on CIFAR-10, the framework improved the GAUC from 0% to 29.5%.
  • Adversarial Robustness for BNNs: On MNIST, the certified robust accuracy of a BNN was improved from 60.2% to 74.6%.
  • Distributional Robustness: In a novel specification where the noise distribution itself is uncertain, the framework improved GAUC from 5.4% to 23.2% using "LinExp" (Linear-Exponential) multipliers.

Discussion and Limitations

While the Functional Lagrangian framework offers significantly tighter bounds, it involves certain trade-offs. The computational cost is higher than simple bound propagation; for example, verifying a VGG-64 model takes approximately 420 seconds per sample compared to 371 seconds for BP. For smaller models like the MLP on MNIST, BP takes about 40 seconds while the FL method adds roughly 39 seconds. Furthermore, the framework's performance is still influenced by the quality of the underlying base bounds (e.g., Interval Bound Propagation).

Future work may focus on extending the theory to unbounded distributions (like standard Gaussians) and further optimizing the computational efficiency of the functional multiplier search. Ultimately, these guarantees are tied to the accuracy of the uncertainty model; if the assumed sensor noise distribution is incorrect, the certified safety may not reflect real-world performance.

Summary updated

BibTeX
@inproceedings{berrada2021verifying,
  author = {Leonard Berrada and Sumanth Dathathri and Krishnamurthy Dvijotham and Robert Stanforth and Rudy Bunel and Jonathan Uesato and Sven Gowal and M. Pawan Kumar},
  title = {{Verifying Probabilistic Specifications with Functional Lagrangians}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2021},
  url = {https://openreview.net/forum?id=xY98nwNSjZ},
}

Loading related content...

Figure