Inferensys

Glossary

TRADES

TRadeoff-inspired Adversarial Defense via Surrogate-loss minimization, a training objective that explicitly balances the trade-off between standard accuracy and adversarial robustness by regularizing the model's output stability.
ML engineer managing model training cluster on laptop, GPU utilization visible, technical deep learning setup.
ADVERSARIAL ROBUSTNESS

What is TRADES?

TRADES is a training objective that explicitly balances the trade-off between standard accuracy and adversarial robustness by regularizing the model's output stability.

TRADES (TRadeoff-inspired Adversarial Defense via Surrogate-loss minimization) is a defensive training algorithm that optimizes a model to be both accurate on clean data and stable under adversarial perturbation. It formalizes the robustness-accuracy trade-off by decomposing the prediction error into a natural error term and a boundary error term, then minimizing a regularized surrogate loss that explicitly penalizes the divergence between a model's prediction on a clean input and its prediction on an adversarially perturbed version of that same input.

Unlike standard adversarial training, which uses the ground-truth label to generate perturbations, TRADES generates perturbations by maximizing the Kullback-Leibler (KL) divergence between the clean and perturbed output distributions. This decoupling of perturbation generation from label information leads to a more principled optimization objective, often yielding superior trade-off curves between clean accuracy and robustness against strong attacks like Projected Gradient Descent (PGD).

THEORETICAL FOUNDATIONS

Key Characteristics of TRADES

TRADES (TRadeoff-inspired Adversarial Defense via Surrogate-loss minimization) is a principled adversarial training objective that explicitly balances the trade-off between natural accuracy and adversarial robustness through a theoretically grounded regularization term.

01

The Surrogate-Loss Minimization Objective

TRADES decomposes the learning problem into two components: empirical risk minimization on natural examples and a robustness regularization term. The objective function is:

min_f E[L(f(x), y) + λ · max_{x'∈B(x,ε)} D(f(x), f(x'))]

  • L(f(x), y): Standard classification loss on clean data
  • D(f(x), f(x')): Divergence between predictions on clean and adversarial examples (typically Kullback-Leibler divergence)
  • λ: Tunable hyperparameter controlling the accuracy-robustness trade-off
  • B(x,ε): Allowed perturbation ball around input x

This formulation directly optimizes the theoretical upper bound on adversarial risk derived by Zhang et al. (2019).

λ > 0
Robustness Weight
02

Accuracy-Robustness Trade-off Control

Unlike standard adversarial training which can overfit to a specific attack strength, TRADES provides explicit control over the trade-off curve:

  • Small λ (e.g., 1.0): Prioritizes natural accuracy, suitable when clean performance is critical
  • Large λ (e.g., 6.0): Prioritizes adversarial robustness, ideal for security-critical applications
  • KL Divergence Regularization: Penalizes output instability rather than forcing correct classification on adversarial examples, leading to smoother decision boundaries

The framework provably bounds the gap between natural and robust error, giving practitioners a principled knob rather than an opaque heuristic.

03

Projected Gradient Descent Inner Maximization

TRADES employs Projected Gradient Descent (PGD) to approximate the worst-case perturbation during training:

  • Inner Loop: Iteratively maximizes the divergence D(f(x), f(x')) within the ε-ball
  • Step Size: Typically set to ε/4 with 10 iterations for CIFAR-10 scale problems
  • Projection: After each gradient step, the perturbed input is projected back onto the L∞ ball of radius ε around the clean input
  • Gradient Propagation: The outer minimization backpropagates through the entire inner maximization process

This bi-level optimization is computationally intensive but yields significantly more robust models than single-step FGSM-based defenses.

04

Relationship to Standard Adversarial Training

TRADES generalizes and improves upon Madry et al.'s adversarial training formulation:

  • Standard AT: Minimizes loss on PGD-generated adversarial examples directly — min E[max L(f(x'), y)]
  • TRADES: Separates natural accuracy from robustness — optimizes clean loss plus prediction stability
  • Key Advantage: TRADES does not require adversarial examples to be correctly labeled; it only requires the model's output distribution to remain stable under perturbation
  • Empirical Results: On CIFAR-10 under L∞ ε=8/255, TRADES achieves ~56% robust accuracy vs ~47% for standard AT at comparable natural accuracy levels

This decoupling makes TRADES particularly effective against strong iterative attacks like AutoAttack.

05

Certified Robustness Connections

The TRADES objective has deep theoretical connections to certified robustness and randomized smoothing:

  • Upper Bound Minimization: TRADES directly minimizes a differentiable surrogate of the robust error upper bound
  • Smoothness Induction: The KL divergence penalty encourages locally Lipschitz-continuous models, a prerequisite for certification
  • Synergy with Randomized Smoothing: Models trained with TRADES serve as stronger base classifiers for randomized smoothing, yielding tighter certified radii
  • Provable Guarantees: Under certain conditions, the TRADES loss provides a certified robustness guarantee against Lp-bounded perturbations

This theoretical grounding distinguishes TRADES from purely empirical defense methods.

06

Implementation Considerations

Practical deployment of TRADES requires careful engineering:

  • Batch Normalization: Use separate batch statistics for clean and adversarial forward passes to avoid distribution mismatch
  • Mixed Precision Training: The bi-level optimization benefits from FP16 acceleration but requires gradient scaling
  • Early Stopping: Monitor both clean and robust validation accuracy; robust accuracy often plateaus before clean accuracy
  • Multi-GPU Distribution: The inner PGD loop is embarrassingly parallel across batch dimensions
  • Learning Rate Scheduling: Cosine annealing with warm restarts typically outperforms step decay for TRADES

Reference implementation available in the Adversarial Robustness Toolbox (ART) and official TRADES GitHub repository.

DEFENSE METHODOLOGY COMPARISON

TRADES vs. Standard Adversarial Training

A technical comparison of the TRADES training objective against standard adversarial training (PGD-AT) across key architectural, optimization, and performance dimensions.

FeatureTRADESStandard Adversarial Training (PGD-AT)Standard Training (No Defense)

Core Objective Function

Minimizes natural loss + boundary regularization term (KL divergence between clean and adversarial logits)

Minimizes empirical risk on adversarial examples only

Minimizes empirical risk on clean examples only

Clean Accuracy Preservation

Explicitly optimized via separate natural error term

Implicitly traded off; often degrades significantly

Maximized by definition

Adversarial Robustness (PGD-40)

High; state-of-the-art on RobustBench

High; but lower than TRADES at equivalent epsilon

Near-zero; fails under trivial perturbations

Hyperparameter Controlling Trade-off

1/lambda (regularization weight); higher lambda favors robustness

Epsilon (perturbation budget); larger epsilon favors robustness

Not applicable

Perturbation Generation During Training

Maximizes KL divergence between clean and perturbed output distributions

Maximizes cross-entropy loss against true label

None

Decision Boundary Characteristic

Smooth, stable boundary with large margin; explicitly regularized

Sharpened but potentially overfitted to attack budget

Sharp, brittle boundary; vulnerable to small perturbations

Certified Robustness Compatibility

Computational Overhead per Epoch

~2-3x standard training (requires clean forward pass + PGD inner loop)

~2-3x standard training (requires PGD inner loop)

1x baseline

TRADES IN DEPTH

Frequently Asked Questions

Explore the mechanics and implementation details of the TRADES defense framework, a foundational algorithm for training adversarially robust deep learning models by explicitly managing the accuracy-robustness trade-off.

TRADES (TRadeoff-inspired Adversarial Defense via Surrogate-loss minimization) is a defensive training algorithm that explicitly balances the trade-off between standard accuracy and adversarial robustness. It works by decomposing the prediction error into a natural error term and a boundary error term. The objective function minimizes the standard cross-entropy loss on clean data while simultaneously adding a regularization term that penalizes the divergence between the model's output probability distributions on clean inputs and their adversarial counterparts. Specifically, TRADES minimizes L(f(x), y) + β * KL(f(x) || f(x')), where x' is the adversarial example generated by maximizing the Kullback-Leibler divergence within an epsilon-ball, and β is a tunable hyperparameter controlling the trade-off. This surrogate-loss approach provides a theoretically grounded mechanism to push the decision boundary away from the data manifold, resulting in smoother model outputs.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.