SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2207.03574 · ICML · 2022

Demystifying the Adversarial Robustness of Random Transformation Defenses

Chawin Sitawarin, David Wagner, Zachary Golan-Strieb

arXiv · PDF · Open in the Atlas

Code that ran

10 of 15 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 8 have no contract verdict; 2 failures of our instrument; 5 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/2207.03574.json · badge: /api/ran/2207.03574.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
wagner-group/demystify-random-transform canonical (classifier label)
classifier basis not recorded on the link
10 ran · 5 no recorded run
FunctionStatusWhere it lives
apply_module Ran
ran on a synthesized input
wagner-group/demystify-random-transform/adv/wrappers/transform/apply_transform.py
code served (permissive licence) · get_code("41b93da2bb253ac1")
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
import torch.nn as nn

torch.manual_seed(0)

# Create a simple input tensor
x = torch.randn(2, 4)

# Create hparams as a dict
hparams = {
    'learning_rate': 0.001,
    'hidden_dim': 8,
}

# Create a simple nn.Module that accepts x and returns a tensor
class SimpleModule(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
    
    def forward(self, x):
        return self.linear(x)

module = SimpleModule()

# same_on_batch is a boolean flag
same_on_batch = False

ARGS = {
    'x': x,
    'hparams': hparams,
    'module': module,
    'same_on_batch': same_on_batch,
}
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
default_conv Ran
ran; our contract draft was wrong, not the code
wagner-group/demystify-random-transform/adv/models/edsr.py
code served (permissive licence) · get_code("8b0e794d4d8f9b13")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Sonnet 4.5, prompt python_fixture_v1) and returned Conv2d. 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 = {
    'in_channels': 3,
    'out_channels': 5,
    'kernel_size': 3,
    'bias': True
}
Setup block drafted by
a language model, Claude Sonnet 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 Conv2d — a Conv2d output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Conv2d 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
diff_round Ran
ran; our contract draft was wrong, not the code
wagner-group/demystify-random-transform/adv/wrappers/transform/utils.py
code served (permissive licence) · get_code("8b8ed141e5ac52c7")
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

torch.manual_seed(0)

x = torch.randn(2, 4, requires_grad=True)

ARGS = {
    "x": x
}
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
evaluate Ran
ran on a synthesized input
wagner-group/demystify-random-transform/train_bpda.py
code served (permissive licence) · get_code("479519ca1a08f97e")
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 float, 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
import torch.nn as nn

torch.manual_seed(0)

# Define a transform callable that takes x and returns (x_new, params)
class Transform:
    def __call__(self, x):
        # Returns transformed x and some parameters
        x_new = x + 0.1
        params = torch.randn(x.shape[0], 2)
        return x_new, params

# Define a simple network that takes x and params
class SimpleNet(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 4)
    
    def forward(self, x, params):
        # Takes x (batch, 4) and params (batch, 2)
        # Returns prediction of same shape as x
        return self.linear(x)

# Define a simple criterion
criterion = nn.MSELoss()

# Create a small dataloader: list of (x, targets) tuples
# x shape: (2, 4), targets shape: (2,) or (2, 1)
dataloader = [
    (torch.randn(2, 4), torch.randint(0, 2, (2,))),
    (torch.randn(2, 4), torch.randint(0, 2, (2,)))
]

# Create network instance
net = SimpleNet()

# Create transform instance
transform = Transform()

# Config dict
config = {"learning_rate": 0.001, "epochs": 10}

# Device
device = torch.device("cpu")

ARGS = {
    "transform": transform,
    "net": net,
    "dataloader": dataloader,
    "criterion": criterion,
    "config": config,
    "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 float, 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
forward Ran
ran on a synthesized input
wagner-group/demystify-random-transform/train_bpda.py
code served (permissive licence) · get_code("f80a1900ef60f141")
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
import torch.nn as nn

torch.manual_seed(0)

# Define a transform that takes x and returns transformed x and parameters
class Transform(nn.Module):
    def __init__(self):
        super().__init__()
    
    def forward(self, x):
        # Returns transformed x and some parameters
        x_new = x * 2.0  # Simple transformation
        params = torch.randn(2, 3)  # Parameters extracted from x
        return x_new, params

# Define a simple net that takes x and params and produces predictions
class Net(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4 + 3, 4)  # x is size 4, params flattened is 3
    
    def forward(self, x, params):
        # Flatten params and concatenate with x
        params_flat = params.view(params.size(0), -1)
        combined = torch.cat([x, params_flat], dim=1)
        return self.linear(combined)

# Define a criterion (loss function)
criterion = nn.MSELoss()

# Create instances
transform = Transform()
net = Net()

# Create input tensor: batch size 2, feature dim 4
x = torch.randn(2, 4)

ARGS = {
    "transform": transform,
    "net": net,
    "criterion": criterion,
    "x": x
}
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
from_numpy Ran
ran on a synthesized input
wagner-group/demystify-random-transform/adv/wrappers/transform/utils.py
code served (permissive licence) · get_code("0aff09aba250ae83")
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 3, dtype family float, shape (2, 4, 3) 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 numpy as np

torch.manual_seed(0)

# The function takes a numpy array, converts it to a torch tensor,
# and permutes dimensions from (H, W, C) to (C, H, W)
# We need a 3D numpy array
x = np.random.randn(4, 3, 2).astype(np.float32)

ARGS = {
    "x": x
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 3, dtype family float, shape (2, 4, 3) — shape (2, 4, 3) 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
init_filter_box Ran
ran on a synthesized input
wagner-group/demystify-random-transform/adv/wrappers/transform/init_transform.py
code served (permissive licence) · get_code("497e85820f3df092")
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 BoxBlur. 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
from kornia.filters import BoxBlur

torch.manual_seed(0)

# Create a minimal hparams dict with the required 'kernel_size' key
# The function uses hparams.get('kernel_size', 3) to retrieve the kernel size
hparams = {
    'kernel_size': 5
}

# same_on_batch parameter - a boolean flag
same_on_batch = False

ARGS = {
    'hparams': hparams,
    'same_on_batch': same_on_batch
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
kornia, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type BoxBlur — a BoxBlur output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a BoxBlur 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
to_numpy Ran
ran on a synthesized input
wagner-group/demystify-random-transform/adv/wrappers/transform/utils.py
code served (permissive licence) · get_code("4efb1ee9419b32b9")
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 ndarray, ndim 3, dtype family float, shape (4, 3, 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)

# The function expects a tensor x with at least 3 dimensions
# It calls x.permute(1, 2, 0) which swaps dimensions
# Then calls .detach().cpu().numpy()
# So x should be a torch tensor with shape (batch, height, width) or similar 3D structure
# Using distinct sizes: batch=2, dim1=4, dim2=3 to avoid ambiguity

x = torch.randn(2, 4, 3)

ARGS = {
    "x": x
}
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 ndarray, ndim 3, dtype family float, shape (4, 3, 2) — shape (4, 3, 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
train Ran
ran on a synthesized input
wagner-group/demystify-random-transform/train_bpda.py
code served (permissive licence) · get_code("95155e6a7662dd5b")
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 float, 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
import torch.nn as nn
import logging

torch.manual_seed(0)

# Define a minimal transform callable
class Transform:
    def __call__(self, x):
        # Returns transformed x and params
        x_new = x * 0.9
        params = torch.randn(x.shape[0], 3)
        return x_new, params

# Define a minimal network
class Net(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 4)
    
    def forward(self, x, params):
        return self.linear(x)

# Define a minimal criterion
criterion = nn.MSELoss()

# Create small dataloaders (list of (x, targets) tuples)
trainloader = [
    (torch.randn(2, 4), torch.randn(2, 4)),
    (torch.randn(2, 4), torch.randn(2, 4)),
]

validloader = [
    (torch.randn(2, 4), torch.randn(2, 4)),
]

# Initialize network and optimizer
net = Net()
optimizer = torch.optim.SGD(net.parameters(), lr=0.01)

# Create config dict with required keys
config = {
    'meta': {
        'save_best_only': False,
        'save_epochs': 1,
    }
}

# Setup logging
log = logging.getLogger('test')
log.setLevel(logging.INFO)
handler = logging.StreamHandler()
log.addHandler(handler)

# Device setup
device = 'cpu'

ARGS = {
    'transform': Transform(),
    'net': net,
    'trainloader': trainloader,
    'validloader': validloader,
    'criterion': criterion,
    'optimizer': optimizer,
    'config': config,
    'epoch': 1,
    'device': device,
    'log': log,
    'best_loss': float('inf'),
    'model_path': '/tmp/model',
    'lr_scheduler': None,
    'log_freq': 1000,
}
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 float, 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
transform_affine Ran
ran on a synthesized input
wagner-group/demystify-random-transform/adv/wrappers/transform/apply_transform.py
code served (permissive licence) · get_code("cab1395888c19cc5")
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
import torch.nn.functional as F

torch.manual_seed(0)

# Construct a small input tensor: batch_size=2, channels=3, height=4, width=4
# F.affine_grid and F.grid_sample expect 4D tensors for images
x = torch.randn(2, 3, 4, 4)

# Construct hparams dict with required keys
hparams = {
    'alpha': 0.1,
    'dist': 'uniform'
}

# same_on_batch parameter
same_on_batch = False

# Define ARGS mapping all parameters
ARGS = {
    'x': x,
    'hparams': hparams,
    'same_on_batch': same_on_batch
}
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
add_normalization Not yet run
unverified (harvested, no recorded run)
wagner-group/demystify-random-transform/adv/models/model_utils.py
code served (permissive licence) · get_code("bee25bf71d9c3982")
How it ran

no invocation recorded.

apply_module_normalize Not yet run
unverified (harvested, no recorded run)
wagner-group/demystify-random-transform/adv/wrappers/transform/apply_transform.py
code served (permissive licence) · get_code("569bf6f75b0e7978")
How it ran

no invocation recorded.

create_model Not yet run
unverified (harvested, no recorded run)
wagner-group/demystify-random-transform/adv/models/model_utils.py
code served (permissive licence) · get_code("23bcc5c1f6613e23")
How it ran

no invocation recorded.

init_horizontal_flip Not yet run
unverified (harvested, no recorded run)
wagner-group/demystify-random-transform/adv/wrappers/transform/init_transform.py
code served (permissive licence) · get_code("f88119c6237118b9")
How it ran

no invocation recorded.

init_vertical_flip Not yet run
unverified (harvested, no recorded run)
wagner-group/demystify-random-transform/adv/wrappers/transform/init_transform.py
code served (permissive licence) · get_code("897337b530ef2ec2")
How it ran

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, 2 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 1 the same month, 2 later) and 13 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
default_conv 57 other papers
20 dated earlier, 1 the same month, 35 later, 1 same year, order not determinable · 2 only as an assembly brick
1707.02921 (2017-07)
Enhanced Deep Residual Networks for Single Image Super-Resolution
1803.02735 (2018-03)
Deep Back-Projection Networks For Super-Resolution
1803.04626 (2018-03)
Maintaining Natural Image Statistics with the Contextual Loss
and 54 more not named here
diff_round 6 other papers
1 dated earlier, 4 later, 1 same year, order not determinable
2108.09034 (2021-08)
AdvDrop: Adversarial Attack to DNNs by Dropping Information
2307.06948 (2023-07)
Self-regulating Prompts: Foundational Model Adaptation without Forgetting
and 3 more not named here

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

Neural networks' lack of robustness against attacks raises concerns in security-sensitive settings such as autonomous vehicles. While many countermeasures may look promising, only a few withstand rigorous evaluation. Defenses using random transformations (RT) have shown impressive results, particularly BaRT (Raff et al., 2019) on ImageNet. However, this type of defense has not been rigorously evaluated, leaving its robustness properties poorly understood. Their stochastic properties make evaluation more challenging and render many proposed attacks on deterministic models inapplicable. First, we show that the BPDA attack (Athalye et al., 2018a) used in BaRT's evaluation is ineffective and likely overestimates its robustness. We then attempt to construct the strongest possible RT defense through the informed selection of transformations and Bayesian optimization for tuning their parameters. Furthermore, we create the strongest possible attack to evaluate our RT defense. Our new attack vastly outperforms the baseline, reducing the accuracy by 83% compared to the 19% reduction by the commonly used EoT attack (4.3× improvement). Our result indicates that the RT defense on Imagenette dataset (a ten-class subset of ImageNet) is not robust against adversarial examples. Extending the study further, we use our new attack to adversarially train RT defense (called AdvRT), resulting in a large robustness gain. Code is available at https://github.com/wagnergroup/demystify-random-transform.

For agents

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

get_harvested_code_for_paper("2207.03574")
get_code_for_paper("2207.03574")
have("2207.03574")

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

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

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

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

Connect an agent — have() is free.