SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1901.08573 · 2019

Theoretically Principled Trade-off between Robustness and Accuracy

U Berkeley, Michael Jordan, Hongyang Zhang, Eric Xing, Yaodong Yu, Jiantao Jiao, Laurent El, Ghaoui Berkeley

arXiv · PDF · Open in the Atlas

Code that ran

12 of 15 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (6 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 7 have no contract verdict; 5 failures of our instrument; 3 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/1901.08573.json · badge: /api/ran/1901.08573.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
arobey1/advbench community
Papers with Code archive
7 ran · 2 no recorded run
copy not recorded community
not in the paper's declared repositories
1 ran · 1 no recorded run
val-iisc/flss community
Papers with Code archive
1 ran · 0 no recorded run
TonyYaoMSU/TRADES community
Papers with Code archive
1 ran · 0 no recorded run
nutellamok/advrush community
Papers with Code archive
1 ran · 0 no recorded run
salomonhotegni/MOREL community
Papers with Code archive
1 ran · 0 no recorded run
FunctionStatusWhere it lives
Attack Ran
ran on a synthesized input · constructed an object; no result was computed
arobey1/advbench/advbench/algorithms.py
code served (permissive licence) · get_code("bca439beb127432f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, Attack: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Create a simple classifier
class SimpleClassifier(nn.Module):
    def __init__(self):
        super(SimpleClassifier, self).__init__()
        self.linear = nn.Linear(4, 3)
    
    def forward(self, x):
        return self.linear(x)

# Create classifier instance
classifier = SimpleClassifier()

# Create hyperparameters dict
hparams = {
    'learning_rate': 0.01,
    'epsilon': 0.1,
    'num_steps': 10,
}

# Set device to CPU
device = torch.device('cpu')

ARGS = {
    'classifier': classifier,
    'hparams': hparams,
    'device': device,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Attack — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a Attack output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
Attack_Linf Ran
ran on a synthesized input · constructed an object; no result was computed
arobey1/advbench/advbench/algorithms.py
code served (permissive licence) · get_code("808053223b371f29")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, Attack_Linf: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Build a minimal classifier that satisfies how it's used
class MinimalClassifier(nn.Module):
    def __init__(self):
        super(MinimalClassifier, self).__init__()
        self.linear = nn.Linear(4, 2)
    
    def forward(self, x):
        return self.linear(x)

# Create instances
classifier = MinimalClassifier()
device = torch.device('cpu')

# Create hparams dict with required 'epsilon' key
hparams = {
    'epsilon': 0.1
}

# Create ARGS dict mapping all parameters
ARGS = {
    'classifier': classifier,
    'hparams': hparams,
    'device': device
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Attack_Linf — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a Attack_Linf output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
AverageMeter Ran
ran on a synthesized input · constructed an object; no result was computed
arobey1/advbench/advbench/algorithms.py
code served (permissive licence) · get_code("61308ee90996cb91")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, AverageMeter: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

ARGS = {
    "avg_mom": 0.5
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type AverageMeter — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a AverageMeter output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
Classifier Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
arobey1/advbench/advbench/algorithms.py
code served (permissive licence) · get_code("95d7d9e951192fbe")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned MNISTNet. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Test case 1: MNIST-like input (1 channel)
input_shape_mnist = (1, 28, 28)
num_classes_mnist = 10
hparams_mnist = {}

ARGS = {
    "input_shape": input_shape_mnist,
    "num_classes": num_classes_mnist,
    "hparams": hparams_mnist
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type MNISTNet — a MNISTNet output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a MNISTNet output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
MNISTNet Ran
ran on a synthesized input · constructed an object; no result was computed
arobey1/advbench/advbench/algorithms.py
code served (permissive licence) · get_code("cc62770b8a2f07cb")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, MNISTNet: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

ARGS = {
    "input_shape": (1, 28, 28),
    "num_classes": 10
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type MNISTNet — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a MNISTNet output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
ResNet18 Ran
ran on a synthesized input
arobey1/advbench/advbench/algorithms.py
code served (permissive licence) · get_code("35e1414137593b9e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ResNet. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# ResNet18 takes no parameters, so ARGS is empty
ARGS = {}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ResNet — a ResNet output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a ResNet output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
TRADES_Linf Ran
ran on a synthesized input · constructed an object; no result was computed
arobey1/advbench/advbench/algorithms.py
code served (permissive licence) · get_code("4cce9cc92ffa9b07")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, TRADES_Linf: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Build a minimal classifier that satisfies how TRADES_Linf uses it
class MinimalClassifier(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)  # 4 input features, 3 output classes
    
    def forward(self, x):
        return self.linear(x)

# Instantiate the classifier
classifier = MinimalClassifier()

# Build hparams dict with required keys used in TRADES_Linf
hparams = {
    'epsilon': 0.3,
    'trades_n_steps': 2,
    'trades_step_size': 0.1,
}

# Set device to CPU
device = 'cpu'

# Create sample inputs: batch of 2 images, each with 4 features
imgs = torch.randn(2, 4, requires_grad=False)
labels = torch.tensor([0, 1])

ARGS = {
    'classifier': classifier,
    'hparams': hparams,
    'device': device,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type TRADES_Linf — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a TRADES_Linf output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
TradesAWP Ran
ran on a synthesized input · constructed an object; no result was computed
val-iisc/flss/CIFAR10/Train/utils_awp.py
pointer only (licence: NONE) · get_code("c1b3357620672711")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, val-iisc/flss when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

trades_loss Ran
ran; our contract draft was wrong, not the code
this paper's copy was not recorded; identical code first harvested from yaodongyu/TRADES
pointer only · get_code("0dbf499b0160d7e3")
How it ran

The body of this sample is withheld: this paper's copy of the code was not recorded (its link names no repository or source path), so no licence was read for it. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

trades_loss Ran
ran; our contract draft was wrong, not the code
TonyYaoMSU/TRADES/TRADES-master/trades.py
pointer only (licence: NONE) · get_code("4f4e01ae4a9aeecf")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, TonyYaoMSU/TRADES when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

trades_loss Ran
ran; our contract draft was wrong, not the code
nutellamok/advrush/advrush/trades.py
code served (permissive licence) · get_code("ae05ac36b5660867")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned Tensor, ndim 0, dtype family float; no output shape is stated. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
import torch.optim as optim

torch.manual_seed(0)

# Define a simple model that returns two outputs (logits and something else)
class SimpleModel(nn.Module):
    def __init__(self, num_classes=5):
        super(SimpleModel, self).__init__()
        self.fc = nn.Linear(4, num_classes)
    
    def forward(self, x):
        logits = self.fc(x)
        return logits, None

# Create model instance
model = SimpleModel(num_classes=5)

# Create small tensors
batch_size = 2
input_dim = 4
num_classes = 5

x_natural = torch.randn(batch_size, input_dim)
y = torch.randint(0, num_classes, (batch_size,))

# Create optimizer
optimizer = optim.SGD(model.parameters(), lr=0.01)

ARGS = {
    'model': model,
    'x_natural': x_natural,
    'y': y,
    'optimizer': optimizer,
    'step_size': 0.003,
    'epsilon': 0.031,
    'perturb_steps': 2,
    'beta': 1.0,
    'distance': 'l_inf'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 0, dtype family float — no output shape is stated: observe_signature.py could not observe it (call:AssertionError)
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
trades_loss Ran
ran; our contract draft was wrong, not the code
salomonhotegni/MOREL/src/advermorel/losses/trades.py
code served (permissive licence) · get_code("e79913f3ab121c59")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned Tensor, ndim 0, dtype family float; no output shape is stated. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
import torch.optim as optim

torch.manual_seed(0)

# Define a simple model that takes input and produces logits
class SimpleModel(nn.Module):
    def __init__(self, input_dim=12, num_classes=3):
        super(SimpleModel, self).__init__()
        self.fc1 = nn.Linear(input_dim, 8)
        self.fc2 = nn.Linear(8, num_classes)
    
    def forward(self, x):
        x = torch.relu(self.fc1(x))
        x = self.fc2(x)
        return x

# Create model and optimizer
model = SimpleModel(input_dim=12, num_classes=3)
optimizer = optim.SGD(model.parameters(), lr=0.01)

# Create batch of natural examples (batch_size=2, flattened input_dim=12)
x_natural = torch.rand(2, 12)

# Create labels (batch_size=2, num_classes=3)
y = torch.tensor([0, 2])

ARGS = {
    'model': model,
    'x_natural': x_natural,
    'y': y,
    'optimizer': optimizer,
    'step_size': 0.007,
    'epsilon': 0.031,
    'perturb_steps': 10,
    'beta': 1.0,
    'distance': 'l_inf',
    'clip_values': (0.0, 1.0),
    'extra_outputs': False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 0, dtype family float — no output shape is stated: observe_signature.py could not observe it (call:AssertionError)
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
Algorithm Not yet run
unverified (harvested, no recorded run)
arobey1/advbench/advbench/algorithms.py
code served (permissive licence) · get_code("afdbbd69eb450e7d")
How it ran

no invocation recorded.

TRADES Not yet run
unverified (harvested, no recorded run)
arobey1/advbench/advbench/algorithms.py
code served (permissive licence) · get_code("8af50e8650fba9a4")
How it ran

no invocation recorded.

TRADES_loss Not yet run
unverified (harvested, no recorded run)
this paper's copy was not recorded; identical code first harvested from zjfheart/Friendly-Adversarial-Training
pointer only; the stored copy get_code serves, from zjfheart/Friendly-Adversarial-Training, is pointer only (licence: NONE) · get_code("310d3d6ec0329c05")
How it ran

The body of this sample is withheld: this paper's copy of the code was not recorded (its link names no repository or source path), so no licence was read for it. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

Also present in other papers' code

Of 15 samples lifted from this paper's linked repositories, 15 carry a function identity and 0 do not. Of the 15 distinct functions with an identity, 3 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 3 later) and 12 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
TRADES_loss
brick of this paper's assembly: entry
2 other papers
1 dated earlier, 1 later
1706.06083 (2017-06)
Towards Deep Learning Models Resistant to Adversarial Attacks
2303.00250 (2023-03)
Combating Exacerbated Heterogeneity for Robust Models in Federated Learning
trades_loss
brick of this paper's assembly: entry
2 other papers
2 later
1910.09338 (2019-10)
An Alternative Surrogate Loss for PGD-based Adversarial Testing
aaai_26027 (2023 (year only))
Learning Adversarially Robust Sparse Networks via Weight Reparameterization
ResNet18
brick of this paper's assembly: helper
1 other paper
1 later
2402.19302 (2024-02)
DiffAssemble: A Unified Graph-Diffusion Model for 2D and 3D Reassembly

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

We identify a trade-off between robustness and accuracy that serves as a guiding principle in the design of defenses against adversarial examples. Although this problem has been widely studied empirically, much remains unknown concerning the theory underlying this trade-off. In this work, we decompose the prediction error for adversarial examples (robust error) as the sum of the natural (classification) error and boundary error, and provide a differentiable upper bound using the theory of classification-calibrated loss, which is shown to be the tightest possible upper bound uniform over all probability distributions and measurable predictors. Inspired by our theoretical analysis, we also design a new defense method, TRADES, to trade adversarial robustness off against accuracy. Our proposed algorithm performs well experimentally in real-world datasets. The methodology is the foundation of our entry to the NeurIPS 2018 Adversarial Vision Challenge in which we won the 1st place out of ~2,000 submissions, surpassing the runner-up approach by 11.41% in terms of mean 2 perturbation distance.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("1901.08573")
get_code_for_paper("1901.08573")
have("1901.08573")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/1901.08573.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/1901.08573.svg)](https://syntology.ai/paper/1901.08573)

Connect an agent — have() is free.