TRADES Loss (TRadeoff-inspired Adversarial DEfense via Surrogate-loss minimization) is a loss function that balances natural accuracy against adversarial robustness by minimizing the Kullback-Leibler (KL) divergence between a model's output distribution on a clean input and its output distribution on an adversarially perturbed version of that same input. Unlike standard adversarial training, which directly minimizes the cross-entropy loss on adversarial examples, TRADES decomposes the objective into a natural error term and a boundary error term, providing a principled mechanism to control the trade-off between classifying clean data correctly and maintaining stable predictions near the decision boundary.
Glossary
TRADES Loss

What is TRADES Loss?
A formal definition of the TRADES loss function, which optimizes the trade-off between standard accuracy and adversarial robustness in deep learning models.
The formulation introduces a regularization hyperparameter, λ, that explicitly governs the trade-off: the natural error term optimizes for standard accuracy, while the boundary error term penalizes the model when its probabilistic output diverges under perturbation. This approach is theoretically grounded in a decomposition of a model's robust error, proving that the gap between natural and robust error is bounded by the expected KL divergence between clean and adversarial output distributions. TRADES has become a foundational baseline in the RobustBench leaderboard, often outperforming standard Projected Gradient Descent (PGD) adversarial training in achieving higher robust accuracy without sacrificing excessive clean accuracy.
Key Characteristics of TRADES Loss
TRADES (TRadeoff-inspired Adversarial DEfense via Surrogate-loss minimization) is a loss function that formalizes the trade-off between natural accuracy and adversarial robustness by minimizing the Kullback-Leibler divergence between clean and adversarial output distributions.
The Accuracy-Robustness Trade-off
TRADES directly addresses the fundamental tension between natural accuracy (performance on clean data) and adversarial robustness (resistance to perturbations). The loss function is formulated as:
L_TRADES = L_CE(f(x), y) + β * KL(f(x) || f(x'))
- The first term is standard cross-entropy loss for clean accuracy
- The second term is the Kullback-Leibler divergence between the clean output distribution and the adversarial output distribution
- The hyperparameter β controls the trade-off: higher β prioritizes robustness over accuracy
KL Divergence Regularization
Unlike adversarial training which uses the label of the adversarial example directly, TRADES uses the model's own prediction on the clean input as the soft target for the adversarial example. This encourages output stability:
- The model learns to produce similar probability distributions for clean and perturbed inputs
- This prevents the model from becoming overconfident on adversarial examples
- The KL divergence term acts as a local smoothness regularizer around each data point
- Results in smoother decision boundaries that are harder to exploit
Adversarial Example Generation
TRADES generates adversarial examples using Projected Gradient Descent (PGD) to maximize the KL divergence between clean and perturbed outputs:
- The perturbation is constrained within an Lp-norm ball (typically L∞ with radius ε)
- Uses multi-step PGD with random initialization for stronger attacks
- The inner maximization finds the perturbation that causes the largest output distribution shift
- This is more aligned with robustness goals than maximizing classification error alone
Theoretical Foundation
TRADES provides a principled upper bound on the robust error of a classifier. The theoretical decomposition shows:
- Robust error ≤ Natural error + Boundary error
- Natural error is the error on clean samples
- Boundary error measures how often the model's prediction changes within the perturbation neighborhood
- TRADES minimizes both terms simultaneously
- This formalization explains why robustness and accuracy can conflict and provides a framework for managing the trade-off
Comparison to Standard Adversarial Training
Standard adversarial training (Madry et al.) uses one-hot labels for adversarial examples, while TRADES uses the model's own soft predictions on clean data:
- Standard AT:
L_CE(f(x'), y)— forces correct classification of perturbed inputs - TRADES:
L_CE(f(x), y) + β * KL(f(x) || f(x'))— forces output consistency - TRADES often achieves higher clean accuracy at equivalent robustness levels
- Particularly effective when β is tuned appropriately for the dataset and threat model
- Widely adopted as a strong baseline in adversarial robustness research
Practical Implementation Considerations
Key implementation details for effective TRADES training:
- β selection: Typically ranges from 1.0 to 6.0; higher values for stronger robustness requirements
- PGD steps: 10-step PGD is standard during training; more steps increase computational cost
- Step size: Usually set to ε/4 for L∞ perturbations with radius ε = 8/255
- Training time: Approximately 2-3x slower than standard training due to adversarial example generation
- Evaluation: Use AutoAttack for reliable robustness assessment rather than PGD alone
- Available in libraries like Adversarial Robustness Toolbox (ART) and RobustBench
TRADES Loss vs. Standard Adversarial Training
A feature-level comparison between the TRADES loss function and standard adversarial training for optimizing the trade-off between natural accuracy and adversarial robustness.
| Feature | TRADES Loss | Standard Adversarial Training |
|---|---|---|
Core objective | Minimize natural error + boundary error | Minimize adversarial error directly |
Loss function composition | Cross-entropy on clean data + KL divergence regularization | Cross-entropy on adversarial examples only |
Clean data utilization | ||
Theoretical grounding | Decomposes robust error into natural and boundary components | Empirical risk minimization on adversarial distribution |
Natural accuracy preservation | High (explicitly optimized) | Moderate to Low (often degrades) |
Hyperparameter controlling trade-off | 1/λ (regularization coefficient) | ε (perturbation radius) |
Gradient computation | Requires second backward pass for KL divergence term | Single backward pass on adversarial examples |
Sensitivity to perturbation step size | Lower (smoother optimization landscape) | Higher (can overfit to specific ε) |
Frequently Asked Questions
Clear, technical answers to the most common questions about the TRADES loss function and its role in building adversarially robust financial fraud detection models.
The TRADES loss (TRadeoff-inspired Adversarial DEfense via Surrogate-loss) is a training objective that balances a model's accuracy on clean, natural data against its robustness to adversarial perturbations. It works by minimizing a composite loss: the standard cross-entropy loss for natural accuracy plus a regularization term that minimizes the Kullback-Leibler (KL) divergence between the model's output probability distribution on a clean sample and its distribution on an adversarially perturbed version of that same sample. This forces the decision boundary to be smooth, pushing it away from the data manifold and making it difficult for an attacker to find a nearby misclassified input. The trade-off is controlled by a hyperparameter, typically denoted as 1/λ, which weights the importance of robustness relative to natural accuracy.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Core concepts that interact with TRADES loss to form a complete adversarial defense framework.
Adversarial Training
The foundational defensive technique that augments training data with adversarial examples. TRADES is a specific adversarial training algorithm that improves upon standard approaches by explicitly optimizing the trade-off between natural accuracy and robustness.
- Standard AT minimizes loss on adversarial examples only
- TRADES minimizes a clean loss plus a regularization term
- The regularization term is the KL divergence between clean and adversarial output distributions
Projected Gradient Descent (PGD)
The standard white-box attack used to generate adversarial examples during TRADES training. PGD iteratively perturbs an input within an Lp-norm ball to maximize the loss.
- TRADES uses PGD to generate the adversarial variant of each clean input
- The perturbation budget epsilon defines the maximum allowed distortion
- Multi-step PGD with random starts is the de facto evaluation standard
Kullback-Leibler Divergence
The statistical distance measure at the heart of TRADES. It quantifies how much one probability distribution diverges from a reference distribution.
- TRADES minimizes KL(p_clean || p_adversarial)
- This forces the model's output on adversarial inputs to match its output on clean inputs
- Unlike cross-entropy, KL divergence is asymmetric and captures distributional shift

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us