Detection-Based Defenses
What you'll learn: How to identify adversarial examples by detecting anomalies and statistical signatures that distinguish them from legitimate inputs.
Core Idea
Rather than making your model inherently robust (like adversarial training does), detection-based defenses aim to spot adversarial examples before they fool your model. Think of it like airport security: instead of making passengers invulnerable to threats, you screen them to detect threats before they board.
These defenses work on a key insight: adversarial perturbations, while imperceptible to humans, often create detectable statistical anomalies in the input space or model's internal representations.
Detection Approaches
Statistical Tests
Examine input distributions for deviations. Adversarial examples may have unusual pixel statistics, frequency domain characteristics, or fail consistency checks that natural images pass. For example, measuring the local intrinsic dimensionality—adversarial examples often lie in lower-dimensional subspaces.
Auxiliary Classifiers
Train a separate "detector" model alongside your main classifier. This auxiliary network learns to distinguish clean vs. adversarial inputs by analyzing:
- Input characteristics directly
- Internal activations from the target model
- Confidence patterns (adversarial examples often produce unusual confidence distributions)
Anomaly Detection Methods
Treat adversarial examples as out-of-distribution samples. Techniques include:
- One-class SVM or isolation forests on feature representations
- Reconstruction error from autoencoders (adversarial inputs reconstruct poorly)
- Density estimation to flag low-probability regions
The Challenge
Adaptive attackers can craft examples that evade detection mechanisms themselves—this becomes an arms race. Detectors work best when attackers don't know the detection method.
Key Takeaway: Detection-based defenses identify adversarial examples through statistical anomalies, auxiliary classifiers, and outlier detection, acting as a filter before classification rather than hardening the model itself.