SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2103.01208 · ICML · 2021

Mind the Box: l 1 -APGD for Sparse Adversarial Attacks on Image Classifiers

Matthias Hein, Francesco Croce

arXiv · PDF · Open in the Atlas

Code that ran

10 of 12 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 9 failures of our instrument; 2 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/2103.01208.json · badge: /api/ran/2103.01208.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
jeromerony/adversarial-library canonical (classifier label)
classifier basis: classifier_2025
7 ran · 1 no recorded run
fra31/auto-attack extension (classifier label)
classifier basis: classifier_2025
3 ran · 1 no recorded run
FunctionStatusWhere it lives
APGDAttack Ran
ran on a synthesized input
fra31/auto-attack/autoattack/autopgd_base.py
code served (permissive licence) · get_code("dfd8fbbc663ac95e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 2, 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

# Create a simple mock model for testing
class MockModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 2)
    
    def forward(self, x):
        return self.linear(x)

# Create mock predict function
def mock_predict(x):
    model = MockModel()
    return model(x)

INIT_ARGS = {
    'predict': mock_predict,
    'n_iter': 10,
    'norm': 'Linf',
    'n_restarts': 1,
    'eps': 0.3,
    'seed': 0,
    'loss': 'ce',
    'eot_iter': 1,
    'rho': 0.75,
    'topk': None,
    'verbose': False,
    'device': None,
    'use_largereps': False,
    'is_tf_model': False,
    'logger': None,
}

ARGS = {
    'x': torch.randn(2, 4),
    'y': torch.tensor([0, 1]),
}

METHOD = 'perturb'
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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 2, dtype family float — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
L1_norm Ran
ran; our contract draft was wrong, not the code
fra31/auto-attack/autoattack/autopgd_base.py
code served (permissive licence) · get_code("edab3f9c146ad457")
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 1, dtype family float, shape (2,) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape 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)

# Create a small tensor with batch size 2 and multiple dimensions
# Shape: (batch=2, height=4, width=3) to have distinct dimension sizes
x = torch.randn(2, 4, 3)

ARGS = {
    "x": x,
    "keepdim": 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 1, dtype family float, shape (2,) — shape (2,) as a later run recorded it
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
L1_projection Ran
ran; our contract draft was wrong, not the code
fra31/auto-attack/autoattack/autopgd_base.py
code served (permissive licence) · get_code("7325c49fd8c6a7d2")
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 2, dtype family float, shape (2, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape 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)

# x2: center of the L1 ball (bs x input_dim)
x2 = torch.rand(2, 4)

# y2: current perturbation (bs x input_dim)
y2 = torch.rand(2, 4) * 0.1

# eps1: radius of the L1 ball
eps1 = 0.5

ARGS = {
    "x2": x2,
    "y2": y2,
    "eps1": eps1,
}
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 2, dtype family float, shape (2, 4) — shape (2, 4) as a later run recorded it
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
_apgd Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
jeromerony/adversarial-library/adv_lib/attacks/auto_pgd.py
code served (permissive licence) · get_code("70c177095b43730b")
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 tuple. 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
from torch import nn
import torch.nn.functional as F

torch.manual_seed(0)

# Build a minimal model that takes inputs and returns logits
class SimpleModel(nn.Module):
    def __init__(self, input_dim=4, num_classes=3):
        super().__init__()
        self.linear = nn.Linear(input_dim, num_classes)
    
    def forward(self, x):
        # Flatten spatial dimensions if needed
        batch_size = x.shape[0]
        x_flat = x.view(batch_size, -1)
        return self.linear(x_flat)

# Create model
model = SimpleModel(input_dim=4, num_classes=3)

# Create inputs: batch_size=2, shape=(2, 1, 4)
inputs = torch.rand(2, 1, 4)

# Create labels: batch_size=2, values in [0, 2]
labels = torch.tensor([0, 1])

# Create eps: batch_size=2
eps = torch.tensor([0.1, 0.1])

# Define ARGS dict with all parameters
ARGS = {
    'model': model,
    'inputs': inputs,
    'labels': labels,
    'eps': eps,
    'norm': float('inf'),
    'x_init': None,
    'targeted': False,
    'n_iter': 10,
    'loss_function': 'dlr',
    'eot_iter': 1,
    'rho': 0.75
}
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 tuple — a tuple output has no array shape of its own; none is 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
check_oscillation Ran
ran; our contract draft was wrong, not the code
jeromerony/adversarial-library/adv_lib/attacks/auto_pgd.py
code served (permissive licence) · get_code("5d25f9fb43f3d226")
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 Tensor, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape 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
from torch import nn, Tensor

torch.manual_seed(0)

# Construct loss_steps: a tensor where the first dimension is indexed by j
# The function accesses loss_steps[j - counter5] and loss_steps[j - counter5 - 1]
# for counter5 in range(k), so we need at least j + 1 elements
# Let's use j=5, k=3, so we need loss_steps with at least 6 timesteps
# Each element should be a scalar tensor (or have shape []) for the comparison and add_ operations

# Create loss_steps as a 1D tensor of length 7 (to safely index up to j=5 with k=3)
# Shape: [7] - 7 loss values over time
loss_steps = torch.rand(7)

j = 5
k = 3
k3 = 0.75

ARGS = {
    "loss_steps": loss_steps,
    "j": j,
    "k": k,
    "k3": k3
}
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 Tensor, ndim 0, dtype family float, shape () — shape () as a later run recorded it
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
difference_of_logits Ran
ran; our contract draft was wrong, not the code
jeromerony/adversarial-library/adv_lib/attacks/auto_pgd.py
code served (permissive licence) · get_code("e8b6ca4f669623e7")
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 Tensor, ndim 1, dtype family float, shape (2,) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape 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
from torch import nn, Tensor

torch.manual_seed(0)

# Create small tensors for the function
batch_size = 2
num_classes = 4

logits = torch.randn(batch_size, num_classes)
labels = torch.tensor([1, 3])

ARGS = {
    "logits": logits,
    "labels": labels,
    "labels_infhot": None,
}
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 Tensor, ndim 1, dtype family float, shape (2,) — shape (2,) as a later run recorded it
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
difference_of_logits_ratio Ran
ran; our contract draft was wrong, not the code
jeromerony/adversarial-library/adv_lib/attacks/auto_pgd.py
code served (permissive licence) · get_code("929e775a8340f085")
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 Tensor, ndim 1, dtype family float, shape (2,) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape 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
from torch import Tensor

torch.manual_seed(0)

# Create small tensors for testing
batch_size = 2
num_classes = 4

logits = torch.randn(batch_size, num_classes)
labels = torch.randint(0, num_classes, (batch_size,))
labels_infhot = torch.zeros_like(logits).scatter_(1, labels.unsqueeze(1), float('inf'))
targeted = False
epsilon = 0.0

ARGS = {
    "logits": logits,
    "labels": labels,
    "labels_infhot": labels_infhot,
    "targeted": targeted,
    "ε": epsilon,
}
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 Tensor, ndim 1, dtype family float, shape (2,) — shape (2,) as a later run recorded it
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
generate_random_targets Ran
ran; our contract draft was wrong, not the code
jeromerony/adversarial-library/adv_lib/utils/attack_utils.py
code served (permissive licence) · get_code("0832e3bf9440362b")
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 1, dtype family int, shape (4,) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape 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)

# Create small test tensors
labels = torch.tensor([0, 2, 1, 3])  # batch size 4, values in range [0, 3]
num_classes = 4

ARGS = {
    "labels": labels,
    "num_classes": num_classes,
}
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 1, dtype family int, shape (4,) — shape (4,) as a later run recorded it
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
get_all_targets Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
jeromerony/adversarial-library/adv_lib/utils/attack_utils.py
code served (permissive licence) · get_code("c6344b8a7b36aea8")
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 2, dtype family int, shape (2, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape 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
from torch import Tensor

torch.manual_seed(0)

# Create a small labels tensor with shape (2,)
# Labels should be in range [0, num_classes)
labels = torch.tensor([1, 3], dtype=torch.long)

# Number of classes
num_classes = 5

ARGS = {
    "labels": labels,
    "num_classes": num_classes,
}
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 2, dtype family int, shape (2, 4) — shape (2, 4) as a later run recorded it
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
l1_projection Ran
ran; our contract draft was wrong, not the code
jeromerony/adversarial-library/adv_lib/attacks/auto_pgd.py
code served (permissive licence) · get_code("bbb91aff6f54a002")
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 Tensor, ndim 2, dtype family float, shape (2, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape 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 math

torch.manual_seed(0)

# Create small test tensors
# x: input tensor of shape (batch_size, feature_dim)
# y: reference tensor of shape (batch_size, feature_dim)
# eps: small epsilon tensor for numerical stability

batch_size = 2
feature_dim = 4

x = torch.randn(batch_size, feature_dim)
y = torch.randn(batch_size, feature_dim)
eps = torch.tensor(1e-8)

ARGS = {
    "x": x,
    "y": y,
    "eps": eps,
}
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 Tensor, ndim 2, dtype family float, shape (2, 4) — shape (2, 4) as a later run recorded it
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
apgd Not yet run
unverified (harvested, no recorded run)
jeromerony/adversarial-library/adv_lib/attacks/auto_pgd.py
code served (permissive licence) · get_code("bcf13be809e95acc")
How it ran

no invocation recorded.

check_zero_gradients Not yet run
unverified (harvested, no recorded run)
fra31/auto-attack/autoattack/autopgd_base.py
code served (permissive licence) · get_code("dfcb6366ce0d55d8")
How it ran

no invocation recorded.

Also present in other papers' code

Of 12 samples lifted from this paper's linked repositories, 12 carry a function identity and 0 do not. Of the 12 distinct functions with an identity, 5 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 1 the same month, 3 later) and 7 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
L1_projection
brick of this paper's assembly: helper
8 other papers
1 dated earlier, 1 the same month, 6 later · 2 only as an assembly brick
1511.00561 (2015-11)
SegNet: A Deep Convolutional Encoder-Decoder Architecture for Image Segmentation
2103.14222 (2021-03)
Adversarial Attacks are Reversible with Natural Supervision
2105.12508 (2021-05)
Adversarial Robustness against Multiple and Single l p -Threat Models via Quick Fine-Tuning of Robust Classifiers
and 5 more not named here
generate_random_targets 3 other papers
3 dated earlier
1812.06371 (2018-12)
Trust Region Based Adversarial Attack on Neural Networks
1907.02044 (2019-07)
Minimally distorted Adversarial Examples with a Fast Adaptive Boundary Attack
2003.01690 (2020-03)
Reliable Evaluation of Adversarial Robustness with an Ensemble of Diverse Parameter-free Attacks
get_all_targets 3 other papers
3 dated earlier
1812.06371 (2018-12)
Trust Region Based Adversarial Attack on Neural Networks
1907.02044 (2019-07)
Minimally distorted Adversarial Examples with a Fast Adaptive Boundary Attack
2003.01690 (2020-03)
Reliable Evaluation of Adversarial Robustness with an Ensemble of Diverse Parameter-free Attacks
L1_norm
brick of this paper's assembly: helper
1 other paper
1 later
2312.01260 (2023-12)
Rethinking PGD Attack: Is Sign Function Necessary?
difference_of_logits
brick of this paper's assembly: helper
1 other paper
1 later
2402.01879 (2024-02)
σ-ZERO: GRADIENT-BASED OPTIMIZATION OF ℓ 0 -NORM ADVERSARIAL EXAMPLES

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 show that when taking into account also the image domain [0, 1] d , established l 1 -projected gradient descent (PGD) attacks are suboptimal as they do not consider that the effective threat model is the intersection of the l 1 -ball and [0, 1] d . We study the expected sparsity of the steepest descent step for this effective threat model and show that the exact projection onto this set is computationally feasible and yields better performance. Moreover, we propose an adaptive form of PGD which is highly effective even with a small budget of iterations. Our resulting l 1 -APGD is a strong white-box attack showing that prior works overestimated their l 1 -robustness. Using l 1 -APGD for adversarial training we get a robust classifier with SOTA l 1 -robustness. Finally, we combine l 1 -APGD and an adaptation of the Square Attack to l 1 into l 1 -AutoAttack, an ensemble of attacks which reliably assesses adversarial robustness for the threat model of l 1 -ball intersected with [0, 1] d .

For agents

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

get_harvested_code_for_paper("2103.01208")
get_code_for_paper("2103.01208")
have("2103.01208")

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

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

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

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

Connect an agent — have() is free.