Adversarial Sample Detection Through Neural Network Transport Dynamics

Skander Karkar, Patrick Gallinari, Alain Rakotomamonjy

TL;DR

This paper introduces a novel adversarial sample detector that treats neural networks as dynamical systems, identifying "abnormal" inputs by analyzing their trajectories through the network's layers. By incorporating a "Least Action Principle" (LAP) regularization during training—derived from optimal transport theory—the authors make clean data trajectories more predictable and distinct, significantly improving detection performance and even boosting standard test accuracy.

What Problem Does This Paper Address?

Deep neural networks are notoriously vulnerable to adversarial attacks: small, human-imperceptible perturbations that cause a model to misclassify an input with high confidence. Because these models are often "overconfident" even when wrong, simple softmax-based detection fails.

Existing detectors often rely on complex statistical computations (like Mahalanobis distances) or batch-level statistics, which can be computationally expensive or require specific data distributions. Furthermore, many defense mechanisms that improve robustness (making the model harder to fool) don't necessarily make the adversarial samples easier to detect. This paper seeks a lightweight, effective detection method specifically suited for modern residual-style architectures (ResNets, WideResNets, etc.) that views the transformation of data through layers as a continuous flow.

Methods

The authors propose two synergistic contributions:

  1. The Transport Detector (TR): Based on the analogy that Residual Networks (ResNets) are discrete Euler discretizations of ordinary differential equations (ODEs), the authors view the network as a vector field moving inputs through space. For each layer $m$, they extract two simple features from the residual $r_m(x_m)$: its squared norm and its cosine similarity to a fixed vector of ones. These features, collected across all layers, form a trajectory profile that a Random Forest classifier uses to distinguish clean from adversarial samples.
  2. Least Action Principle (LAP) Regularization: To make these trajectories more informative, the authors add a regularization term during training that minimizes the "kinetic energy" of the transformation: $\sum \|r_m(x_m)\|^2$. This is grounded in optimal transport theory, effectively finding the "shortest path" to transform the input distribution into the class-separated output distribution.
Fig. 1. Transformed circles test set from scikit-learn (red and blue) and out-of- distribution points (green) after blocks 6 and 9 of a small ResNet with 9 blocks. In the second row, we add our proposed regularization during training, which makes the movements of the clean points (red and blue) more similar to each other and more different from the movements of the green out-of-distribution points than when using the vanilla network in the first row. In particular, without the regularization, the green points are closer to the clean red points after blocks 6 and 9 which is undesirable.

As seen in Figure 1, applying this regularization (bottom row) "straightens" the flow of clean data (red and blue points), making their movements more similar to each other and more distinct from out-of-distribution or adversarial points (green).

Datasets

The authors evaluated their approach across three standard benchmarks using diverse architectures:

  • CIFAR-10 using a ResNet110.
  • CIFAR-100 using a ResNeXt50.
  • TinyImageNet using a WideResNet.
  • SVHN was used as an unseen dataset for evaluating Out-of-Distribution (OOD) detection capabilities.

They tested against eight different attacks, including white-box (FGM, BIM, DeepFool, CW, AutoAttack, APGD) and black-box (HSJ, Boundary Attack) methods.

Key Insights and Ideas

  • Adversarial Samples are "Off-Manifold": The core intuition is that while clean data follows a regular manifold, adversarial perturbations push samples into "co-dimensions" where the network's behavior hasn't been regularized.
  • Regularity vs. Robustness: Most methods try to make the network Lipschitz-continuous everywhere to improve robustness. This paper argues for making the network regular only on the support of the clean data. This doesn't necessarily make the model harder to fool, but it makes the "weird" behavior of adversarial samples much more obvious to a detector.
  • Efficiency: Unlike statistical detectors that require computing batch-wide means and covariances, the TR detector uses simple norms and cosines that are extremely fast to compute during a standard forward pass.
  • Dynamical View of Depth: By treating depth as time, the authors leverage the mathematical tools of optimal transport to prove that their regularization makes the internal residual blocks Hölder-continuous on the data manifold.

Key Results

  • Superior Detection: The TR detector consistently outperformed state-of-the-art methods like the Mahalanobis (MH) detector. For example, on CIFAR-10 with a vanilla ResNet110, TR outperformed MH by 9 to 16 percentage points across various attacks.
  • Generalization to Unseen Attacks: When trained only on simple FGM attacks, the TR detector generalized remarkably well to more complex, unseen attacks like AutoAttack and DeepFool, often maintaining detection rates above 90%.
  • Accuracy Boost: Unlike many adversarial defenses that trade off standard accuracy for safety, LAP training actually improved test accuracy (e.g., from 74.38% to 77.2% on CIFAR-100).
  • Speed: The TR detector is significantly faster than the Mahalanobis method, taking roughly 60% of the time to extract features and train.

Limitations and Future Work

The authors note that while LAP training improves detection for "seen" attacks, it can sometimes slightly reduce generalization to completely "unseen" attack types by reducing the variance of features the detector relies on.

Additionally, while the detector is robust against adaptive attacks (where the attacker knows about the detector), a sophisticated attacker can still reduce detection rates to about 85% in the worst-case scenario. Future work could involve exploring more complex "time-dependent" vector fields or applying these dynamical insights to Vision Transformers, which also utilize residual connections.

Summary updated

BibTeX
@inproceedings{karkar2023adversarial,
  author = {Skander Karkar and Patrick Gallinari and Alain Rakotomamonjy},
  title = {{Adversarial Sample Detection Through Neural Network Transport Dynamics}},
  booktitle = {International Conference on Learning Representations},
  year = {2023},
  url = {https://openreview.net/forum?id=NYjXrU_f20G},
}
Figure