Subset Scanning Over Neural Network Activations

Skyler Speakman, Srihari Sridharan, Sekou L. Remy, Komminist Weldemariam, Edward McFowlandarXiv 2018

Introduction

Neural networks are notoriously overconfident. Even when presented with gibberish or carefully crafted adversarial noise, they often assign high-probability labels to incorrect answers. This research, presented at AAAI 2019, proposes a novel approach to provide these models with a sense of "self-awareness" by monitoring their internal activation states. By treating a neural network’s hidden layer activations as a data-generating system, the authors apply Subset Scanning—a technique from anomalous pattern detection—to identify when a network is processing an unusual input.

Problem Statement: The "Black Box" Challenge

Deep learning models typically lack mechanisms to signal when they encounter out-of-distribution (OOD) data or adversarial examples. Existing defenses often require retraining models with specific adversarial examples, supervised labels for "bad" data, or dimensionality reduction that might discard subtle signals.

The core challenge lies in detecting anomalies within the high-dimensional "activation space"—the vector of values produced by hidden layers. In a typical network, this space can encompass tens of thousands of nodes. Searching for a specific anomalous pattern among $2^N$ possible subsets of nodes is computationally intractable through brute force.

Methodology: Non-parametric Scan Statistics

The authors introduce Non-parametric Scan Statistics (NPSS) to analyze neural activations through the following steps:

  1. Establishing a Baseline: A set of "normal" (clean) images is passed through the network to establish a background distribution of expected activation values for every node.
  2. Empirical P-values: For new inputs, each node’s activation is compared to its baseline to generate an empirical $p$-value. Activations significantly higher or lower than the norm result in $p$-values near zero.
  3. Subset Scanning: Rather than analyzing nodes individually or the entire layer at once, the method searches for the subset of nodes whose $p$-values collectively deviate most significantly from a uniform distribution.
  4. Linear Time Subset Scanning (LTSS): To maintain computational efficiency, the authors leverage the LTSS property. This mathematical shortcut identifies the globally optimal subset in log-linear time ($O(J \log J)$ for $J$ nodes), making the search feasible even for large layers.
  5. Scoring: The Berk-Jones test statistic is used to quantify how much the observed $p$-values in a subset deviate from random chance.

Key Insights: Activations as Sensors

A primary insight of this work is viewing the neural network as a complex sensor system. If the "sensors" (neurons) exhibit unprecedented behavior, the input is likely untrustworthy. The authors observed an "interference" pattern where adversarial noise suppresses the original image's activation structure in deeper layers.

Distribution of subset representation scores for clean and adversarial inputs across layers.

As shown in the distributions above, adversarial inputs (orange) often shift the subset representation significantly compared to clean inputs (blue), particularly in intermediate layers like Pool 1 and Conv 4. This unsupervised, model-agnostic approach allows for detection without prior knowledge of specific attack types.

Experimental Results

The method was evaluated on a 7-layer CNN trained on CIFAR-10, tested against FGSM, BIM, and CW attacks.

Detection performance (AUC) across different network layers for various adversarial attacks.

The results demonstrate high detection power for strong adversarial perturbations. For FGSM and BIM attacks ($\epsilon = 0.1$), the method achieved an Area Under the ROC Curve (AUC) exceeding 0.99. Notably, scanning for a specific subset significantly outperformed scoring "all nodes" in a layer. For instance, on a BIM attack ($\epsilon=0.05$), subset scanning achieved an AUC of 0.8755, compared to 0.6961 when using all nodes. The first pooling layer (Pool 1) emerged as particularly sensitive to pixel-space changes.

Discussion and Future Work

While effective, the method faces challenges with ReLU activation functions, which often output zero and complicate the definition of "extreme" behavior. Additionally, low-confidence attacks (e.g., CW with $\kappa=0$) remain difficult to detect, with AUCs near 0.5.

Future research may explore "hard constraints" to ensure anomalous nodes are physically connected within the network architecture, potentially reducing false positives. Furthermore, identifying the most informative layers to monitor will be crucial for scaling this approach to massive modern architectures like Transformers.

Summary updated

BibTeX
@misc{speakman2018subset,
  author = {Skyler Speakman and Srihari Sridharan and Sekou L. Remy and Komminist Weldemariam and Edward McFowland},
  title = {{Subset Scanning Over Neural Network Activations}},
  year = {2018},
  eprint = {1810.08676},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1810.08676},
}
Figure