Defensive Distillation
What you'll learn: How to use knowledge distillation with temperature scaling to make models less sensitive to adversarial perturbations.
The Core Idea
Defensive distillation is a defense technique that trains a model to be "softer" in its predictions, making it harder for adversaries to exploit sharp decision boundaries. It leverages knowledge distillation—normally used for model compression—but repurposes it for robustness.
Here's how it works:
-
Train a teacher model on your dataset normally, but use a high temperature parameter during the softmax operation. This creates "soft" probability distributions instead of hard predictions (like [0.6, 0.3, 0.1] instead of [1, 0, 0]).
-
Train a student model to match these soft labels from the teacher, also using the same high temperature during training.
-
Deploy the student at normal temperature (T=1) for inference.
Why This Helps
The high temperature forces the model to learn the relationships between classes (which outputs are somewhat similar) rather than just making confident, sharp predictions. This smoother decision surface is less sensitive to small input perturbations—the model's output changes more gradually when inputs are slightly modified.
Think of it like training someone to be less overconfident: instead of saying "I'm 100% certain this is a cat," they say "I'm 70% sure it's a cat, 20% it's a dog, 10% something else." This nuanced understanding is harder to fool with small tricks.
Limitations
While defensive distillation showed early promise, it has been largely broken by adaptive attacks like C&W, which specifically account for the gradient masking effect it creates. Modern defenses like adversarial training and certified defenses are now preferred.
Key Takeaway: Defensive distillation uses temperature-scaled knowledge distillation to smooth decision boundaries, reducing sensitivity to perturbations, though it's been superseded by more robust defense methods.