Abstract
Adversarial attacks pose a significant threat to the reliability of Deep Neural Networks (DNNs). This paper presents NNIF (Nearest Neighbor Influence Functions), a reactive defense mechanism that detects adversarial samples by identifying a discrepancy between a model's training data and its test-time predictions. By comparing the training samples that most influence a prediction with those that are physically closest in the model's internal representation, NNIF achieves state-of-the-art detection accuracy across multiple benchmarks and attack types.
Introduction: The Vulnerability of Deep Learning
Deep Neural Networks are notoriously susceptible to adversarial attacks—small, often imperceptible perturbations to input data that cause misclassification with high confidence. While proactive defenses aim to harden models, reactive defenses act as "smoke detectors" to identify malicious inputs during inference. A key challenge in reactive defense is that adversarial samples often appear statistically normal in the final layers of a network, making them difficult to distinguish from clean data using standard methods.
Methodology: Bridging Influence and Proximity
The proposed NNIF method leverages two distinct perspectives on the relationship between a test input and the training set:
- Influence Functions: This statistical technique identifies which training samples were most "helpful" (supported the prediction) or "harmful" (pushed it toward error) for a specific test input.
- $k$-Nearest Neighbors ($k$-NN): This identifies training samples that are physically closest to the test input in the model's embedding space (the penultimate layer).
The core insight of this work is that for natural, "normal" images, these two metrics are highly correlated: the images that influence a prediction are typically found in the same local neighborhood of the embedding space. In contrast, for adversarial samples, this relationship breaks down. The "helpful" training samples are often far away from the adversarial input in the internal feature space.
By extracting the ranks and distances of the most influential training samples, the authors train a simple Logistic Regression classifier to serve as an adversarial detector.
Experimental Results
The NNIF detector was evaluated on CIFAR-10, CIFAR-100, and SVHN datasets against six diverse attack methods, including FGSM, DeepFool, and Carlini-Wagner (CW).
Key findings include:
- State-of-the-Art Accuracy: NNIF achieved an AUC of 99.96% against FGSM on CIFAR-10 and maintained high performance against more sophisticated optimization-based attacks like DeepFool (99.32%).
- Generalization: Detectors trained on simple attacks successfully generalized to unseen, more complex attacks, indicating that NNIF captures a fundamental characteristic of adversariality rather than specific attack signatures.
- Robustness: The method proved resilient even in "white-box" scenarios where the attacker is aware of the detector, with only a marginal drop in performance (approx. 1%).
Discussion and Future Work
While NNIF provides a powerful defense, its primary limitation is the computational overhead associated with calculating the Hessian matrix for influence functions. Future research will focus on optimizing these calculations through approximate nearest neighbor searches or hash maps to enable real-time deployment in safety-critical applications like autonomous driving.
Summary updated