SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2407.06315 · ECCV · 2024

Shedding More Light on Robust Classifiers under the lens of Energy-based Models

Iacopo Masi, Mujtaba Hussain Mirza, Maria Briglia, Senad Beadini

arXiv · PDF · Open in the Atlas

Code that ran

7 of 10 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; 7 failures of our instrument; 3 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2407.06315.json · badge: /api/ran/2407.06315.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
omnai-lab/robust-classifiers-under-the-lens-of-ebm canonical (classifier label)
classifier basis: census
4 ran · 3 no recorded run
OmnAI-Lab/Robust-Classifiers-under-the-lens-of-EBM community
Papers with Code archive
3 ran · 0 no recorded run
FunctionStatusWhere it lives
WEAT_adv Ran
ran; our contract draft was wrong, not the code
OmnAI-Lab/Robust-Classifiers-under-the-lens-of-EBM/Adversarial ML/WEAT_loss.py
code served (permissive licence) · get_code("fb79541499d1aa7e")
How it ran

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

import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.optim import SGD

torch.manual_seed(0)

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

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

# Create natural input data (batch_size=2, input_dim=4)
x_natural = torch.randn(2, 4)

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

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

# Define ARGS dictionary with all parameters
ARGS = {
    'model': model,
    'x_natural': x_natural,
    'y': y,
    'optimizer': optimizer,
    'step_size': 0.007,
    'epsilon': 0.031,
    'perturb_steps': 10,
    'beta': 7.0
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 0, dtype family float — no output shape is stated: observe_signature.py could not observe it (call:AssertionError)
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
call_bn Ran
ran; our contract draft was wrong, not the code
omnai-lab/robust-classifiers-under-the-lens-of-ebm/image_generation/norms.py
code served (permissive licence) · get_code("112fb9db5c4e35cc")
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 torch.nn as nn

torch.manual_seed(0)

# Create a BatchNorm1d module
bn = nn.BatchNorm1d(num_features=4)

# Create a small input tensor (batch_size=2, features=4)
x = torch.randn(2, 4)

# Set training mode to True for testing
bn.train()

# Define ARGS dict with all parameters
ARGS = {
    'bn': bn,
    'x': x,
    'update_batch_stats': True
}
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
compute_weights Ran
ran; our contract draft was wrong, not the code
OmnAI-Lab/Robust-Classifiers-under-the-lens-of-EBM/Adversarial ML/WEAT_loss.py
code served (permissive licence) · get_code("f2e90ad69c40bd2a")
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)

# The function takes 'energy' as a parameter and applies mathematical operations on it
# energy should be a tensor that supports torch operations like log, exp, abs

energy = torch.randn(2, 4)

ARGS = {
    "energy": energy
}
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
energy_x Ran
ran; our contract draft was wrong, not the code
OmnAI-Lab/Robust-Classifiers-under-the-lens-of-EBM/Adversarial ML/WEAT_loss.py
code served (permissive licence) · get_code("3b02bed9d1de1c13")
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

torch.manual_seed(0)

# The function energy_x takes logits and computes -torch.logsumexp(logits, dim=1)
# logits should be a 2D tensor where dim=1 is the class/event dimension
# We'll create a small batch of logits: batch_size=2, num_classes=4

logits = torch.randn(2, 4)

ARGS = {
    "logits": logits
}
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
get_norm Ran
ran; our contract draft was wrong, not the code
omnai-lab/robust-classifiers-under-the-lens-of-ebm/image_generation/norms.py
code served (permissive licence) · get_code("5c287586436a7685")
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 BatchNorm2d. 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 = {
    'n_filters': 16,
    'norm': '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 BatchNorm2d — a BatchNorm2d output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a BatchNorm2d 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
load_tiny_imagenet Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
omnai-lab/robust-classifiers-under-the-lens-of-ebm/Robustnes_test/dataset_loader.py
code served (permissive licence) · get_code("68eabfc0ae125aee")
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.utils.data as data
import torchvision.transforms as transforms
from torch.utils.data import Dataset

torch.manual_seed(0)

class MockTinyImageNetDataset(Dataset):
    def __init__(self, num_samples=10):
        self.num_samples = num_samples
        self.transform = transforms.Compose([
            transforms.Resize(256),
            transforms.CenterCrop(224),
            transforms.ToTensor()
        ])
    
    def __len__(self):
        return self.num_samples
    
    def __getitem__(self, idx):
        # Return a small 3-channel image and a label
        img = torch.randint(0, 256, (3, 224, 224), dtype=torch.uint8)
        label = torch.tensor(idx % 200, dtype=torch.long)
        return img, label

# Mock the load_tinyimagenet function
def mock_load_tinyimagenet(data_dir):
    train_dataset = MockTinyImageNetDataset(num_samples=5)
    test_dataset = MockTinyImageNetDataset(num_samples=5)
    return train_dataset, test_dataset

# Patch the import
import sys
from unittest.mock import MagicMock
mock_module = MagicMock()
mock_module.load_tinyimagenet = mock_load_tinyimagenet
sys.modules['robustbenchmaster'] = MagicMock()
sys.modules['robustbenchmaster.robustbench'] = MagicMock()
sys.modules['robustbenchmaster.robustbench.load_tiny_imagenet'] = mock_module

PREPROCESSINGS = {
    'Res256Crop224': transforms.Compose([transforms.Resize(256), transforms.CenterCrop(224), transforms.ToTensor()]),
    'Crop288': transforms.Compose([transforms.CenterCrop(288), transforms.ToTensor()]),
    None: transforms.Compose([transforms.ToTensor()]),
    'Res224': transforms.Compose([transforms.Resize(224), transforms.ToTensor()]),
    'BicubicRes256Crop224': transforms.Compose([transforms.Resize(256, interpolation=transforms.InterpolationMode('bicubic')), transforms.CenterCrop(224), transforms.ToTensor()])
}

ARGS = {
    'n_examples': 10,
    'data_dir': '/tmp/tiny-imagenet-200/',
    'transforms_test': PREPROCESSINGS['Res256Crop224']
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
robustbenchmaster, torch, torchvision — 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
ti_ResNet18 Ran
ran; our contract draft was wrong, not the code
omnai-lab/robust-classifiers-under-the-lens-of-ebm/Robustnes_test/ti_resnet.py
code served (permissive licence) · get_code("33f9787e2217480f")
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 ti_ResNet. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

ARGS = {
    "classes": 10
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ti_ResNet — a ti_ResNet output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a ti_ResNet output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
load_cifar10 Not yet run
unverified (harvested, no recorded run)
omnai-lab/robust-classifiers-under-the-lens-of-ebm/image_generation/utils.py
code served (permissive licence) · get_code("f4b0898be0b428b7")
How it ran

no invocation recorded.

load_cifar100 Not yet run
unverified (harvested, no recorded run)
omnai-lab/robust-classifiers-under-the-lens-of-ebm/image_generation/utils.py
code served (permissive licence) · get_code("681c8eb66d1b4ebc")
How it ran

no invocation recorded.

load_svhn Not yet run
unverified (harvested, no recorded run)
omnai-lab/robust-classifiers-under-the-lens-of-ebm/Robustnes_test/dataset_loader.py
code served (permissive licence) · get_code("d512774ae8b4915f")
How it ran

no invocation recorded.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 10 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.

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

By reinterpreting a robust discriminative classifier as Energybased Model (EBM), we offer a new take on the dynamics of adversarial training (AT). Our analysis of the energy landscape during AT reveals that untargeted attacks generate adversarial images much more indistribution (lower energy) than the original data from the point of view of the model. Conversely, we observe the opposite for targeted attacks. On the ground of our thorough analysis, we present new theoretical and practical results that show how interpreting AT energy dynamics unlocks a better understanding: (1) AT dynamic is governed by three phases and robust overfitting occurs in the third phase with a drastic divergence between natural and adversarial energies (2) by rewriting TRADES loss in terms of energies, we show that TRADES implicitly alleviates overfitting by means of aligning the natural energy with the adversarial one (3) we empirically show that all recent state-of-the-art robust classifiers are smoothing the energy landscape and we reconcile a variety of studies about understanding AT and weighting the loss function under the umbrella of EBMs. Motivated by rigorous evidence, we propose Weighted Energy Adversarial Training (WEAT), a novel sample weighting scheme that yields robust accuracy matching the state-of-the-art on multiple benchmarks such as CIFAR-10 and SVHN and going beyond in CIFAR-100 and Tiny-ImageNet. We further show that robust classifiers vary in the intensity and quality of their generative capabilities, and offer a simple method to push this capability, reaching a remarkable Inception Score (IS) and FID using a robust classifier without training for generative modeling. The code to reproduce our results is available at github.com/OmnAI-Lab/Robust-Classifiers-under-the-lens-of-EBM.

For agents

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

get_harvested_code_for_paper("2407.06315")
get_code_for_paper("2407.06315")
have("2407.06315")

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

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

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

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

Connect an agent — have() is free.