Navigation

Introduction to AI

Machine Learning

Deep Learning

Generative AI

Tools & Frameworks

General

Adversarial Robustness

Adversarial robustness addresses a fundamental vulnerability of deep learning: carefully crafted small perturbations to inputs can cause models to make confident, incorrect predictions. An imperceptibly modified image can fool an image classifier; a few characters added to text can mislead a sentiment classifier.

This is both a research problem (understanding why models are vulnerable) and a security problem (ensuring AI systems are reliable in adversarial settings).

The Adversarial Vulnerability

Example: Adversarial Image

A deep CNN correctly classifies an image as “panda” with 58% confidence. An attacker adds a small, imperceptible noise pattern:

$$x_{adversarial} = x + \epsilon$$

where $\epsilon$ is chosen to maximize the model’s error. The resulting image, visually indistinguishable from the original to humans, now causes the model to classify it as “gibbon” with 99% confidence.

Why Does This Happen?

Deep neural networks are highly non-linear, with millions of parameters. In high dimensions, they can be surprisingly brittle:

  • Linear hypothesis: Neural networks may be more linear than we expect in data manifolds, making them vulnerable to linear perturbations.
  • Sharp loss landscape: Models may have sharp, narrow decision boundaries. Small moves perpendicular to the boundary cause misclassification.
  • Superposition: Adversarial perturbations exploit the superposition of learned features in ways humans don’t perceive.

Adversarial Attack Methods

FGSM (Fast Gradient Sign Method)

The simplest and fastest attack:

$$x_{adv} = x + \epsilon \cdot \text{sign}(\nabla_x L(x, y))$$

where $L$ is the loss function and $y$ is the true label. Move in the direction of the gradient by a small step $\epsilon$.

Computational cost: O(1 forward-backward pass) per attack.

Effective? Yes, but easily defended against (see Defensive Distillation).

PGD (Projected Gradient Descent)

A stronger, iterative attack:

$$x_{t+1} = \text{Clip}_{x+S}(x_t + \alpha \cdot \text{sign}(\nabla_x L(x_t, y)))$$

where $\text{Clip}$ projects onto an $\epsilon$-ball around the original input $x$, and $S$ is the allowed perturbation set.

Computational cost: Multiple iterations (e.g., 20 steps), more expensive than FGSM.

Effectiveness: More robust than FGSM; harder to defend against.

C&W (Carlini & Wagner)

Uses an optimization algorithm to find the smallest perturbation:

$$\min_{x’} ||x’ - x||_2^2 + c \cdot L(x’)$$

subject to $x’ \in [0, 1]^d$ (valid input range).

Computational cost: High (iterative optimization).

Effectiveness: Very strong; breaks many defense mechanisms.

Black-Box Attacks

An attacker has no access to model gradients. Strategies:

  • Transferability: Generate adversarial examples for a surrogate model; often transfer to the target model.
  • Query-based attacks: Query the model many times to approximate gradients.
  • Decision-based attacks: Use only the model’s predicted class (not confidence scores).

Defense Mechanisms

Adversarial Training

Train the model on adversarial examples:

  1. For each training batch, generate adversarial examples using an attack method (e.g., PGD).
  2. Train the model to correctly classify both clean and adversarial examples.

$$\min_\theta \mathbb{E}{x, y} \left[ L(\theta, x, y) + L(\theta, x{adv}, y) \right]$$

Effectiveness: Improves robustness significantly.

Trade-off: Reduces accuracy on clean (non-adversarial) examples, increases training time.

Defensive Distillation

Train a “defensive” model by distilling a base model through high-temperature softmax:

$$T = t, \quad L = \text{KL}(\text{softmax}(f_{\text{base}}(x) / t), \text{softmax}(f_{\text{defense}}(x) / t))$$

High temperature $t$ reduces the sharpness of predictions, making gradients smaller and attacks less effective.

Effectiveness: Moderate; gradient-based attacks can adapt (BPDA — Backward Pass Differentiable Approximation).

Input Transformations

Preprocess inputs to remove adversarial perturbations:

  • JPEG compression: Quantization can destroy fine-grained adversarial noise.
  • Bit-depth reduction: Lower precision removes high-frequency components.
  • Morphological operations: Erosion/dilation to smooth perturbations.

Limitation: Attacks can adapt to transformations; not a robust defense alone.

Certified Robustness

Compute formal guarantees that no adversarial perturbation of size $\epsilon$ can fool the model:

Using randomized smoothing:

  1. Add Gaussian noise to the input: $x’ = x + \delta, \delta \sim \mathcal{N}(0, \sigma^2 I)$.
  2. Classify $x’$ multiple times and take a majority vote.
  3. For appropriate $\sigma$ and sample counts, this provides a certified robustness bound.

Advantage: Formal guarantees (worst-case, adversarial robustness).

Trade-off: Typically requires lower accuracy or smaller certified radius.

TRADES (Trade-off Adjustment)

Balance clean accuracy and robust accuracy by training on both:

$$L_{\text{TRADES}} = L_{\text{clean}} + \beta \cdot L_{\text{robust}}$$

where $L_{\text{robust}}$ is computed on adversarial examples. The hyperparameter $\beta$ controls the trade-off.

The Adversarial Robustness-Accuracy Trade-off

Increasing adversarial robustness often decreases clean accuracy:

  • Standard training: ~95% clean accuracy, ~0% robustness to adversarial examples.
  • Adversarial training with ε = 8/255: ~85% clean accuracy, ~50% robustness to PGD attacks.

This trade-off is fundamental and widely observed. Improving both simultaneously remains an open problem.

Transferability and Domain Shift

Adversarial examples often transfer across models:

  • An adversarial example that fools ResNet-50 often fools VGG-16.
  • This raises security concerns (attackers don’t need to know the target model) but enables transferability-based defenses.

Transfer is stronger for similar architectures; it decreases for models trained differently (e.g., adversarially vs. standardly trained).

Applications and Domains

Autonomous Vehicles

Adversarial patches on stop signs can fool object detectors, creating safety risks. Robustness is critical.

Malware Detection

Adversarial examples in machine learning-based intrusion detection. Adversarial robustness needed for security systems.

NLP

Adversarial text attacks add typos or synonym replacements to fool text classifiers. Defenses are less mature than in vision.

Current Challenges

Computational cost: Adversarial training is expensive (10-100x slower than standard training).

Certified vs. empirical robustness: Certified defenses provide formal guarantees but often have large certified radii that are impractical. Empirical robustness is harder to guarantee.

Adaptive attacks: Defenses designed against specific attacks often fail to adaptive attacks that are aware of the defense.

Scalability: Current defenses don’t scale well to large models (e.g., large language models).

Research Directions

  • Efficient adversarial training: Reducing computational overhead.
  • Understanding robustness: Why do some models learn more robust features than others?
  • Certified defenses at scale: Extending certified robustness to large, practical models.
  • Multimodal robustness: Adversarial attacks and defenses for vision-language models.

Adversarial robustness remains a fundamental challenge for deploying deep learning in safety-critical systems, with implications for security, reliability, and trustworthiness of AI.