VRA: Out-of-Distribution Detection with variational rectified activations

Mingyu Xu, Zheng Lian

TL;DR

This paper introduces Variational Rectified Activation (VRA), a novel post-hoc method for Out-of-Distribution (OOD) detection. VRA, derived from a theoretical variational approach, not only suppresses high activations but also addresses abnormally low activations and amplifies intermediate ones, outperforming existing methods on benchmark datasets.

What Problem Does This Paper Address?

In real-world applications, machine learning models often encounter data that differs from their training distribution, known as Out-of-Distribution (OOD) data. This can lead to overconfident predictions, compromising system reliability. OOD detection aims to identify these unfamiliar samples, allowing models to reject them. While techniques like ReAct have shown promise by truncating high activations to increase the separation between in-distribution (ID) and OOD data, the paper questions if this is the optimal strategy. The core problem is to find a more effective way to distinguish between ID and OOD data using post-hoc methods, which are desirable for their ease of implementation.

Methods

The authors approach this problem by first theoretically deriving an optimal activation function using a variational method. This method aims to maximize the gap between ID and OOD data while minimizing modifications to the original activations. The derived optimal function, $g^*(z)$, suggests suppressing both abnormally low and high activations and amplifying intermediate ones.

To implement this theoretically derived function, which depends on the unknown probability distributions of ID ($p_{in}$) and OOD ($p_{out}$) data, the paper proposes Variational Rectified Activation (VRA). VRA is a piecewise function that simulates these suppression and amplification operations using two thresholds, $\alpha$ and $\beta$. They further introduce VRA+, which adds a hyperparameter $\gamma$ to control the amplification of intermediate activations. An adaptive strategy is used to determine $\alpha$ and $\beta$ by using quantiles of activations from ID data, which is shown to be more effective than fixed thresholds.

Datasets

The experiments were conducted on several standard datasets:

  • ID Datasets: CIFAR-10, CIFAR-100, and ImageNet.
  • OOD Datasets: For CIFAR, they used Textures, SVHN, Places365, LSUN-Crop, LSUN-Resize, and iSUN. For ImageNet, they used iNaturalist, SUN, Places, and Textures.

Key Insights and Ideas

  • Beyond High Activation Suppression: The theoretical derivation reveals that simply suppressing high activations (like ReAct) is not sufficient. Abnormally low activations also need to be suppressed, and intermediate activations should be amplified to maximize the ID-OOD gap.
  • Variational Optimization for OOD: Applying variational methods to find an optimal activation function provides a principled way to address the OOD detection problem.
  • Adaptive Thresholding is Crucial: Using quantiles of ID data activations to set thresholds ($\alpha, \beta$) for VRA is more effective than using fixed values, highlighting the importance of adapting to the specific data distribution.
  • VRA+ Enhances Performance: The VRA+ variant, which explicitly amplifies intermediate activations, generally outperforms VRA, suggesting that a closer approximation to the theoretically derived optimal function leads to better results.

Key Results

  • VRA and VRA+ consistently outperform existing state-of-the-art post-hoc OOD detection strategies across multiple benchmark datasets (CIFAR-10, CIFAR-100, ImageNet).
  • The paper reports achieving new state-of-the-art results with their proposed methods. For instance, on CIFAR-10 with DenseNet-101, VRA+ achieves an AUROC of 96.90% and an FPR95 of 15.89%.
  • VRA is shown to be compatible with various scoring functions (MSP, Energy, ODIN) and network architectures (DenseNet-101, ResNet-50, ResNetv2-101).
  • In ideal scenarios where a small fraction of OOD data is known, VRA can achieve near-perfect performance, demonstrating its strong potential.

Limitations and Future Work

  • Approximation of Optimal Function: VRA uses piecewise functions to approximate the theoretically derived optimal activation. The paper suggests exploring other functional forms that might better capture the optimal operation.
  • Dependence on $p_{in}$ and $p_{out}$ Estimation: The theoretical optimal function relies on knowing the probability distributions of ID and OOD data. While VRA uses practical approximations, accurately estimating these distributions remains a challenge, especially for unknown OOD data.
  • Further Analysis of BatchNorm and Architectures: The authors note that while ReAct's effectiveness is sometimes attributed to BatchNorm statistics, their experiments suggest network architecture also plays a significant role, and further in-depth analysis is needed.
  • Exploring Alternative Regularization Terms: The paper mentions that while maximizing the gap is the core objective, better regularization terms could be explored to ensure the existence and interpretability of the optimal solution.

Summary updated

Abstract

Out-of-distribution (OOD) detection is critical to building reliable machine learning systems in the open world. Researchers have proposed various strategies to reduce model overconfidence on OOD data. Among them, ReAct is a typical and effective technique to deal with model overconfidence, which truncates high activations to increase the gap between in-distribution and OOD. Despite its promising results, is this technique the best choice for widening the gap? To answer this question, we leverage the variational method to find the optimal operation and verify the necessity of suppressing abnormally low and high activations and amplifying intermediate activations in OOD detection, rather than focusing only on high activations like ReAct. This motivates us to propose a novel technique called ``Variational Rectified Activation (VRA)'', which simulates these suppression and amplification operations using piecewise functions. Experimental results on multiple benchmark datasets demonstrate that our method outperforms existing post-hoc strategies. Meanwhile, VRA is compatible with different scoring functions and network architectures. \textcolor[rgb]{0.93,0.0,0.47}{Our code can be found in Supplementary Material}.
BibTeX
@inproceedings{xu2023vra,
  author = {Mingyu Xu and Zheng Lian},
  title = {{VRA: Out-of-Distribution Detection with variational rectified activations}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=d0VItRE2ZH},
}
Figure