Course contentsShow
← Machine Learning and Deep Learning
Lesson 3403 of 3,53874. Adversarial RobustnessFree lesson

Adversarial Training Fundamentals

Training models on adversarial examples to improve robustness: basic PGD adversarial training methodology.

Adversarial Training Fundamentals

What you'll learn: How to make models robust by training them directly on adversarial examples using the PGD-based adversarial training methodology.

The Core Idea

Adversarial training is like vaccination for neural networks. Just as vaccines expose your immune system to weakened pathogens so it learns to fight real ones, adversarial training exposes your model to carefully crafted adversarial examples during training so it learns to handle them in deployment.

The basic methodology works like this: During each training iteration, instead of only using clean data, you generate adversarial perturbations for each training batch and train on both. The most widely-used approach employs Projected Gradient Descent (PGD) attacks to create strong adversarial examples on-the-fly.

PGD Adversarial Training Procedure

  1. Start with a mini-batch of clean training examples
  2. Generate PGD adversarial examples for this batch (using the current model weights)
  3. Train on the adversarial examples using standard backpropagation
  4. Repeat for all batches across multiple epochs

This forces the model to learn decision boundaries that are robust not just at the training points, but in a neighborhood around them. The model must correctly classify inputs even when they've been perturbed within the allowed perturbation budget (typically measured by ℓ∞ or ℓ₂ norm).

The PGD attack strength (number of steps, step size) becomes a hyperparameter that balances robustness against clean accuracy—stronger attacks during training typically yield more robust models but may sacrifice some performance on unperturbed data.

Key Takeaway: Adversarial training using PGD-generated examples is the most effective known defense against adversarial attacks, teaching models to maintain correct predictions even under adversarial perturbations by incorporating these examples directly into the training process.