SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2209.07735 · NeurIPS · 2022

Enhance the Visual Representation via Discrete Adversarial Training

Gege Qi, Xiaodan Li, Yuefeng Chen, Hui Xue, Xiaofeng Mao, Ranjie Duan, Yao Zhu, Shaokai Ye, Rong Zhang

arXiv · PDF · Open in the Atlas

Code that ran

10 of 11 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (5 of them constructed an object rather than computing a result; 2 honoured the contract we drafted, 0 violated it and 5 have no contract verdict; 3 failures of our instrument; 1 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/2209.07735.json · badge: /api/ran/2209.07735.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
alibaba/easyrobust canonical (classifier label)
classifier basis: classifier_2025
9 ran · 1 no recorded run
copy not recorded community
not in the paper's declared repositories
1 ran · 0 no recorded run
FunctionStatusWhere it lives
Diffeo Ran
ran on a synthesized input · constructed an object; no result was computed
alibaba/easyrobust/easyrobust/modules/prime.py
code served (permissive licence) · get_code("5f368427f2d48e50")
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, Diffeo: 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 math

torch.manual_seed(0)

ARGS = {
    'sT': 2.0,
    'rT': 0.5,
    'scut': 2.0,
    'rcut': 0.5,
    'cutmin': 1,
    'cutmax': 4,
    'alpha': 0.1,
    'stochastic': False
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, opt_einsum, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Diffeo — 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 Diffeo 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
PRIMEAugModule Ran
ran on a synthesized input · constructed an object; no result was computed
alibaba/easyrobust/easyrobust/modules/prime.py
code served (permissive licence) · get_code("5b26e951879d385b")
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, PRIMEAugModule: 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 simple augmentation modules that take x and return augmented tensor
class SimpleAugmentation(nn.Module):
    def __init__(self, scale=1.0):
        super().__init__()
        self.scale = scale
    
    def forward(self, x):
        return x * self.scale

# Create a list of augmentations
augmentations = [
    SimpleAugmentation(scale=0.5),
    SimpleAugmentation(scale=1.5),
    SimpleAugmentation(scale=2.0),
]

ARGS = {
    'augmentations': augmentations,
}
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 PRIMEAugModule — 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 PRIMEAugModule 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
RandomFilter Ran
ran on a synthesized input · constructed an object; no result was computed
alibaba/easyrobust/easyrobust/modules/prime.py
code served (permissive licence) · get_code("03f527454201d6e7")
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, RandomFilter: 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 numpy as np

torch.manual_seed(0)

# Create a small test image tensor
# Shape: (batch_size, channels, height, width)
test_img = torch.rand(2, 3, 4, 5)

ARGS = {
    'kernel_size': 3,
    'sigma': 0.5,
    'stochastic': False,
    'sigma_min': 0.1
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type RandomFilter — 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 RandomFilter 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
RandomSmoothColor Ran
ran on a synthesized input · constructed an object; no result was computed
alibaba/easyrobust/easyrobust/modules/prime.py
code served (permissive licence) · get_code("b79407df1fc77419")
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, RandomSmoothColor: 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 math

torch.manual_seed(0)

# Create a small test image tensor
# Shape: (batch=2, channels=3, height=4, width=5)
test_image = torch.rand(2, 3, 4, 5)

# Define ARGS dict with all parameters for RandomSmoothColor.__init__
ARGS = {
    'cut': 3,
    'T': 0.5,
    'freq_bandwidth': None,
    'stochastic': False,
    'T_min': 0.0
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, opt_einsum, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type RandomSmoothColor — 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 RandomSmoothColor 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
TransformLayer Ran
ran on a synthesized input · constructed an object; no result was computed
alibaba/easyrobust/easyrobust/modules/prime.py
code served (permissive licence) · get_code("4e905fbdfa4e05cc")
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, TransformLayer: 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)

# TransformLayer.__init__ takes two parameters: mean and std
# These should be array-like objects that can be converted to tensors
# The forward method expects x to be a 4D tensor (batch, channels, height, width)

mean = [0.5, 0.4, 0.3, 0.2]
std = [0.1, 0.15, 0.2, 0.25]

ARGS = {
    "mean": mean,
    "std": std
}
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 TransformLayer — 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 TransformLayer 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
deform Ran
ran; our contract draft was wrong, not the code
alibaba/easyrobust/easyrobust/modules/prime.py
code served (permissive licence) · get_code("49c4bfde12e638af")
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, 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 a small square image tensor
# Shape: [..., y, x] where y=x (square image requirement)
# Using batch size 2 and spatial dims 4x4
image = torch.randn(2, 4, 4, dtype=torch.float32)

# Temperature parameter (controls displacement magnitude)
T = 0.1

# Cutoff for frequency modes
cut = 2

# Interpolation method
interp = 'linear'

ARGS = {
    'image': image,
    'T': T,
    'cut': cut,
    'interp': interp
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
opt_einsum, 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, 4) — shape (2, 4, 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
remap Ran
ran; our contract draft was wrong, not the code
alibaba/easyrobust/easyrobust/modules/prime.py
code served (permissive licence) · get_code("f9efe607667fba03")
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

torch.manual_seed(0)

# Define the arguments for the remap function
# a: Tensor of shape [..., y, x] - we'll use shape [batch, height, width]
a = torch.randn(2, 4, 3)  # batch=2, height=4, width=3

# dx: Tensor of shape [y, x] - displacement in x direction
dx = torch.randn(4, 3) * 0.5

# dy: Tensor of shape [y, x] - displacement in y direction
dy = torch.randn(4, 3) * 0.5

# interp: interpolation method - choose one of 'linear' or 'gaussian'
interp = 'linear'

ARGS = {
    'a': a,
    'dx': dx,
    'dy': dy,
    'interp': interp
}
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 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
scalar_field Ran
ran, honoured the contract we drafted
alibaba/easyrobust/easyrobust/modules/prime.py
code served (permissive licence) · get_code("21e1843fa11d415e")
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 (4, 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)

ARGS = {
    'n': 4,
    'm': 3,
    'device': 'cpu'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
opt_einsum, 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 (4, 4) — shape (4, 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
scalar_field_modes Ran
ran; our contract draft was wrong, not the code
this paper's copy was not recorded; identical code first harvested from pcsl-epfl/diffeomorphism
pointer only · get_code("e57e011fe9cb8615")
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.

temperature_range Ran
ran, honoured the contract we drafted
alibaba/easyrobust/easyrobust/modules/prime.py
code served (permissive licence) · get_code("f8159fb1492781a3")
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, ndim 1, dtype family float; no output shape is stated. The image it ran in was 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 math

torch.manual_seed(0)

# Read the function signature and body:
# - n: used as n ** 2 in arithmetic, so needs to be numeric (int or float)
# - cut: can be int/float OR has a .log() method (like a torch.Tensor)

# Test case 1: both n and cut as simple numerics
ARGS = {
    "n": 5,
    "cut": 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 tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
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
PRIMEAugmentation32 Not yet run
unverified (harvested, no recorded run)
alibaba/easyrobust/easyrobust/modules/prime.py
code served (permissive licence) · get_code("7796b07f8bd25227")
How it ran

no invocation recorded.

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 carry a function identity and 0 do not. Of the 11 distinct functions with an identity, 3 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 0 the same month, 0 later) and 8 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
scalar_field_modes
brick of this paper's assembly: helper
2 other papers
2 dated earlier
2105.02468 (2021-05)
Relative stability toward diffeomorphisms indicates performance in deep nets
2112.13547 (2021-12)
PRIME: A few primitives can boost robustness to common corruptions
deform
brick of this paper's assembly: helper
1 other paper
1 dated earlier
2112.13547 (2021-12)
PRIME: A few primitives can boost robustness to common corruptions
scalar_field
brick of this paper's assembly: helper
1 other paper
1 dated earlier
2112.13547 (2021-12)
PRIME: A few primitives can boost robustness to common corruptions

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

Adversarial Training (AT), which is commonly accepted as one of the most effective approaches defending against adversarial examples, can largely harm the standard performance, thus has limited usefulness on industrial-scale production and applications. Surprisingly, this phenomenon is totally opposite in Natural Language Processing (NLP) task, where AT can even benefit for generalization. We notice the merit of AT in NLP tasks could derive from the discrete and symbolic input space. For borrowing the advantage from NLP-style AT, we propose Discrete Adversarial Training (DAT). DAT leverages VQGAN to reform the image data to discrete text-like inputs, i.e. visual words. Then it minimizes the maximal risk on such discrete images with symbolic adversarial perturbations. We further give an explanation from the perspective of distribution to demonstrate the effectiveness of DAT. As a plug-and-play technique for enhancing the visual representation, DAT achieves significant improvement on multiple tasks including image classification, object detection and self-supervised learning. Especially, the model pre-trained with Masked Auto-Encoding (MAE) and fine-tuned by our DAT without extra data can get 31.40 mCE on ImageNet-C and 32.77% top-1 accuracy on Stylized-ImageNet, building the new state-of-the-art. The code will be available at https://github.com/alibaba/easyrobust. A possible way towards robust machine perception can be Adversarial Training (AT) [5], which automatically finds failure input cases of DNNs and augment online with these cases for fixing "bugs". With online augmentation of adversarial examples, AT greatly enhances the adversarial robustness, and helps for learning perceptually-aligned representations [6] with good interpretability [7,8] and transferability [9]. However, AT is double-edged, which meanwhile degrades the standard performance caused by problematic regularization [10]. Such problematic regularization makes the decision boundaries over-smoothed and enlarges indecisive regions. Surprisingly, previous works [11,12] observe a strange phenomenon that AT behaves conversely in Natural Language Processing (NLP) tasks. By automatically finding adversarial textual inputs, AT will not hurt the accuracy and even benefit for both generalization and robustness of language models. This phenomenon motivates us considering whether the merit of NLP-style AT can be Preprint. Under review.

For agents

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

get_harvested_code_for_paper("2209.07735")
get_code_for_paper("2209.07735")
have("2209.07735")

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

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

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

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

Connect an agent — have() is free.