SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2305.19101 · NeurIPS · 2023

Which Models have Perceptually-Aligned Gradients? An Explanation via Off-Manifold Robustness

Suraj Srinivas, Himabindu Lakkaraju, Sebastian Bordt

arXiv · PDF · Open in the Atlas

Code that ran

6 of 11 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 0 have no contract verdict; 6 failures of our instrument; 5 no recorded run), measured 2026-11-23; 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/2305.19101.json · badge: /api/ran/2305.19101.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
tml-tuebingen/pags canonical (classifier label)
classifier basis: classifier_2025
5 ran · 0 no recorded run
MadryLab/robustness canonical (classifier label)
classifier basis: census
1 ran · 5 no recorded run
FunctionStatusWhere it lives
add_args_to_parser Ran
ran; our contract draft was wrong, not the code
MadryLab/robustness/robustness/defaults.py
code served (permissive licence) · get_code("078da01e51a28471")
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 ArgumentParser. 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 argparse

ARGS = {
    'arg_list': [
        ['learning_rate', float, 'Learning rate for optimization', 0.001],
        ['batch_size', int, 'Batch size for training', 32],
        ['model_type', ['lstm', 'gru', 'transformer'], 'Type of model to use', 'lstm'],
        ['epochs', int, 'Number of training epochs', 10],
        ['optimizer', ['adam', 'sgd'], 'Optimizer to use', 'adam'],
    ],
    'parser': argparse.ArgumentParser(description='Test parser'),
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ArgumentParser — a ArgumentParser output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a ArgumentParser 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
dict2options Ran
ran; our contract draft was wrong, not the code
tml-tuebingen/pags/run_experiments.py
code served (permissive licence) · get_code("05d569aa12038fae")
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 tuple, ndim 2, 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.

settings = {
    'learning_rate': [0.001, 0.01],
    'batch_size': [32, 64],
    'model_path': ['/path/to/model1', '/path/to/model2'],
    'epochs': [10, 20],
    'optimizer': ['adam', 'sgd'],
    'output_filename': ['results.txt']
}

ARGS = {'settings': settings}
Setup block drafted by
a language model, Claude Sonnet 4.5, prompt python_fixture_v1
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 2, 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
get_optimizer_scheduler Ran
ran; our contract draft was wrong, not the code
tml-tuebingen/pags/train_models.py
code served (permissive licence) · get_code("0d11fdf711dd6e20")
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 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 torch.nn as nn

torch.manual_seed(0)

class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
    
    def forward(self, x):
        return self.linear(x)

class Args:
    def __init__(self):
        self.optimizer = 'adam'
        self.lr = 0.001
        self.weight_decay = 0.0001
        self.momentum = 0.9
        self.num_epochs = 100

model = SimpleModel()
args = Args()

ARGS = {
    'args': args,
    'model': model
}
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 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
measure_on_off_manifold_robustness Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
tml-tuebingen/pags/experiments/measure_manifold_robustness.py
code served (permissive licence) · get_code("65b5172b3691e86a")
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 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 torch.nn as nn
import numpy as np

torch.manual_seed(0)

# Create a simple model
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.fc = nn.Linear(2 * 5 * 5, 3)  # batch_dim * img_dim * img_dim -> num_classes
    
    def forward(self, x):
        # x shape: (batch, img_dim, img_dim) or (1, batch, img_dim, img_dim)
        if x.dim() == 3:
            x = x.unsqueeze(0)
        batch_size = x.shape[0]
        x = x.reshape(batch_size, -1)
        return self.fc(x)

model = SimpleModel()

# Create test_loader: list of (img, label) tuples
# Each img should have shape that when squeezed gives (batch_dim, img_dim, img_dim)
test_loader = []
batch_dim = 2
img_dim = 5
num_samples = 3

for i in range(num_samples):
    img = torch.randn(1, batch_dim, img_dim, img_dim)
    label = torch.tensor([i % 3])
    test_loader.append((img, label))

# Create test_tangent_spaces: list of tangent spaces, one per image
# Each tangent space has shape (dim, batch_dim, img_dim, img_dim)
test_tangent_spaces = []
tangent_dim = 4

for i in range(num_samples):
    tangent_space = torch.randn(tangent_dim, batch_dim, img_dim, img_dim)
    test_tangent_spaces.append(tangent_space)

device = torch.device('cpu')

N_images = 2

ARGS = {
    'model': model,
    'test_loader': test_loader,
    'test_tangent_spaces': test_tangent_spaces,
    'device': device,
    'N_images': N_images
}
Setup block drafted by
a language model, Claude Sonnet 4.5, prompt python_fixture_v1
Imports
numpy, scipy, 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
project_into_tangent_space Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
tml-tuebingen/pags/experiments/measure_manifold_robustness.py
code served (permissive licence) · get_code("58244b9a6e3b6f31")
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 ndarray, 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 numpy as np
from scipy.linalg import orth

# Set random seed for reproducibility
np.random.seed(0)

# Create a tangent_space with shape (dim, batch_dim, img_dim, img_dim)
# Using distinct dimensions: dim=3, batch_dim=2, img_dim=4
dim = 3
batch_dim = 2
img_dim = 4

tangent_space = np.random.randn(dim, batch_dim, img_dim, img_dim)

# Create a vector with shape (batch_dim, img_dim, img_dim)
vector = np.random.randn(batch_dim, img_dim, img_dim)

ARGS = {
    'tangent_space': tangent_space,
    'vector': vector
}
Setup block drafted by
a language model, Claude Sonnet 4.5, prompt python_fixture_v1
Imports
numpy, scipy — 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 (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
softmax_l1 Ran
ran; our contract draft was wrong, not the code
tml-tuebingen/pags/experiments/measure_manifold_robustness.py
code served (permissive licence) · get_code("d401cbdf3efe9b60")
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 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 two tensors with shape (batch_size=2, features=4)
# The function applies softmax along dim=1, so we need at least 2D tensors
x = torch.randn(2, 4)
y = torch.randn(2, 4)

ARGS = {
    'x': x,
    'y': y
}
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 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
alexnet Not yet run
unverified (harvested, no recorded run)
MadryLab/robustness/robustness/imagenet_models/alexnet.py
code served (permissive licence) · get_code("3b26d6ebbd9142b2")
How it ran

no invocation recorded.

densenet121 Not yet run
unverified (harvested, no recorded run)
MadryLab/robustness/robustness/imagenet_models/densenet.py
code served (permissive licence) · get_code("85c4757ab3246b61")
How it ran

no invocation recorded.

densenet161 Not yet run
unverified (harvested, no recorded run)
MadryLab/robustness/robustness/imagenet_models/densenet.py
code served (permissive licence) · get_code("6b70762b5419b176")
How it ran

no invocation recorded.

densenet169 Not yet run
unverified (harvested, no recorded run)
MadryLab/robustness/robustness/imagenet_models/densenet.py
code served (permissive licence) · get_code("019686268f24b3b5")
How it ran

no invocation recorded.

model_dataset_from_store Not yet run
unverified (harvested, no recorded run)
MadryLab/robustness/robustness/model_utils.py
code served (permissive licence) · get_code("c1e41af537b4027c")
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, 6 are also present in other papers whose code we hold (6 with at least one paper dated earlier, 1 the same month, 6 later) and 5 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
densenet121 8 other papers
5 dated earlier, 3 later
1905.00641 (2019-05)
RetinaFace: Single-stage Dense Face Localisation in the Wild
1912.00385 (2019-12)
The Group Loss for Deep Metric Learning
2010.11742 (2020-10)
Learning Black-Box Attackers with Transferable Priors and Query Feedback
and 5 more not named here
densenet161 8 other papers
6 dated earlier, 2 later
1905.00641 (2019-05)
RetinaFace: Single-stage Dense Face Localisation in the Wild
1905.11926 (2019-05)
Network Deconvolution
1912.00385 (2019-12)
The Group Loss for Deep Metric Learning
and 5 more not named here
densenet169 8 other papers
6 dated earlier, 2 later
1905.00641 (2019-05)
RetinaFace: Single-stage Dense Face Localisation in the Wild
1905.11926 (2019-05)
Network Deconvolution
1912.00385 (2019-12)
The Group Loss for Deep Metric Learning
and 5 more not named here
alexnet 4 other papers
3 dated earlier, 1 later
1412.6980 (2014-12)
Adam: A Method for Stochastic Optimization
1910.00033 (2019-10)
Hidden Trigger Backdoor Attacks
2010.09080 (2020-10)
Poisoned classifiers are not only backdoored, they are fundamentally broken
and 1 more not named here
model_dataset_from_store 4 other papers
1 dated earlier, 1 the same month, 2 later
2106.02078 (2021-06)
Improving Neural Network Robustness via Persistency of Excitation
2305.14846 (2023-05)
Introducing Competition to Boost the Transferability of Targeted Adversarial Examples through Clean Feature Mixup
2405.08886 (2024-05)
The Pitfalls and Promise of Conformal Inference Under Adversarial Attacks
and 1 more not named here
add_args_to_parser 3 other papers
1 dated earlier, 2 later
2106.02078 (2021-06)
Improving Neural Network Robustness via Persistency of Excitation
2306.00183 (2023-06)
Diffused Redundancy in Pre-trained Representations
2308.06887 (2023-08)
Robustified ANNs Reveal Wormholes Between Human Category Percepts

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-23.

Repositories linked to this paper

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

Abstract

One of the remarkable properties of robust computer vision models is that their input-gradients are often aligned with human perception, referred to in the literature as perceptually-aligned gradients (PAGs). Despite only being trained for classification, PAGs cause robust models to have rudimentary generative capabilities, including image generation, denoising, and in-painting. However, the underlying mechanisms behind these phenomena remain unknown. In this work, we provide a first explanation of PAGs via off-manifold robustness, which states that models must be more robust off-the data manifold than they are on-manifold. We first demonstrate theoretically that off-manifold robustness leads input gradients to lie approximately on the data manifold, explaining their perceptual alignment. We then show that Bayes optimal models satisfy off-manifold robustness, and confirm the same empirically for robust models trained via gradient norm regularization, randomized smoothing, and adversarial training with projected gradient descent. Quantifying the perceptual alignment of model gradients via their similarity with the gradients of generative models, we show that off-manifold robustness correlates well with perceptual alignment. Finally, based on the levels of on-and off-manifold robustness, we identify three different regimes of robustness that affect both perceptual alignment and model accuracy: weak robustness, bayes-aligned robustness, and excessive robustness. Code is available at https://github.com/tml-tuebingen/pags.

For agents

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

get_harvested_code_for_paper("2305.19101")
get_code_for_paper("2305.19101")
have("2305.19101")

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

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

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

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

Connect an agent — have() is free.