Skip to main content
QUICK REVIEW

[Paper Review] Detecting Out-of-Distribution Examples with In-distribution Examples and Gram Matrices

Chandramouli Shama Sastry, Sageev Oore|arXiv (Cornell University)|Dec 28, 2019
Adversarial Robustness in Machine LearningComputer Science33 references21 citations
TL;DR

This paper proposes a novel, zero-shot method for out-of-distribution (OOD) detection that leverages Gram matrices of intermediate feature activations to identify inconsistencies between predicted classes and anomalous activation patterns. By comparing each Gram matrix value to its training-range distribution, the method achieves state-of-the-art OOD detection performance across multiple architectures and datasets without requiring OOD data for tuning or training.

ABSTRACT

When presented with Out-of-Distribution (OOD) examples, deep neural networks yield confident, incorrect predictions. Detecting OOD examples is challenging, and the potential risks are high. In this paper, we propose to detect OOD examples by identifying inconsistencies between activity patterns and class predicted. We find that characterizing activity patterns by Gram matrices and identifying anomalies in gram matrix values can yield high OOD detection rates. We identify anomalies in the gram matrices by simply comparing each value with its respective range observed over the training data. Unlike many approaches, this can be used with any pre-trained softmax classifier and does not require access to OOD data for fine-tuning hyperparameters, nor does it require OOD access for inferring parameters. The method is applicable across a variety of architectures and vision datasets and, for the important and surprisingly hard task of detecting far-from-distribution out-of-distribution examples, it generally performs better than or equal to state-of-the-art OOD detection methods (including those that do assume access to OOD examples).

Motivation & Objective

  • To address the critical challenge of detecting out-of-distribution (OOD) examples in deep neural networks, where models produce overconfident incorrect predictions.
  • To develop a method that detects OOD inputs without requiring access to OOD data during training or hyperparameter tuning.
  • To improve detection performance—especially for far-from-distribution OOD examples—by analyzing feature correlation patterns via Gram matrices.
  • To create a plug-and-play solution compatible with any pre-trained softmax classifier, enabling broad applicability across architectures and vision datasets.

Proposed method

  • Extends standard Gram matrices to compute p-th order feature correlations across activation maps in intermediate layers.
  • Uses the range of Gram matrix values observed during training as a statistical reference for anomaly detection.
  • Identifies OOD examples by detecting values in the test Gram matrix that fall outside the in-distribution training range.
  • Combines the predicted class from the final layer with anomalous activation patterns to flag incongruent predictions.
  • Applies the method directly to pre-trained models without retraining or fine-tuning, enabling zero-shot deployment.
  • Employs a simple thresholding mechanism based on training-range quantiles to flag anomalous Gram matrix entries.

Experimental results

Research questions

  • RQ1Can feature correlation patterns, captured via extended Gram matrices, effectively detect OOD inputs without OOD data?
  • RQ2How does the performance of Gram matrix-based anomaly detection compare to state-of-the-art OOD detection methods that require OOD data?
  • RQ3Can the method generalize across diverse architectures (e.g., ResNet, DenseNet) and datasets (e.g., CIFAR-10, SVHN, LSUN)?
  • RQ4Does the method maintain high performance on challenging far-from-distribution OOD examples?
  • RQ5Can the method be applied effectively to fully connected networks and non-convolutional architectures?

Key findings

  • The method achieves state-of-the-art or competitive AUROC scores on CIFAR-10, CIFAR-100, SVHN, TinyImageNet, LSUN, and iSUN datasets without using any OOD data.
  • On the challenging LSUN OOD set with ResNet-18, the method achieves a TNR@TPR95 of 99.85% and AUROC of 98.66%, outperforming Mahalanobis-based methods.
  • For far-from-distribution OOD examples like LSUN and iSUN, the method consistently outperforms or matches SOTA methods that require OOD data for tuning.
  • The method achieves 97.37% detection accuracy on KMNIST and 96.55% on Fashion-MNIST with a 300-unit MLP, demonstrating effectiveness even on fully connected networks.
  • Combining the method with MSP (Maximum Softmax Probability) further improves performance, achieving 98.66% AUROC on LSUN with ResNet-18.
  • The approach is robust across architectures: it achieves 95.18% AUROC on iSUN with ResNet-18 and 97.82% on TinyImageNet with the same model.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.