SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2406.04724 · ICLR · 2024

ON MINIMIZING ADVERSARIAL COUNTERFACTUAL ER-ROR IN ADVERSARIAL RL

Arunesh Sinha, Pradeep Varakantham, Roman Belaire

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; 1 honoured the contract we drafted, 1 violated it and 0 have no contract verdict; 8 failures of our instrument; 2 no recorded run), measured 2026-11-22; 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/2406.04724.json · badge: /api/ran/2406.04724.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
umd-huang-lab/WocaR-RL canonical (classifier label)
classifier basis: census
8 ran · 2 no recorded run
romanbelaire/acoe-robust-rl canonical (classifier label)
classifier basis: classifier_2025
2 ran · 0 no recorded run
FunctionStatusWhere it lives
activation_bound Ran
ran; our contract draft was wrong, not the code
umd-huang-lab/WocaR-RL/WocaR-DQN/SA-DQN/models.py
code served (permissive licence) · get_code("69017b3a991e0815")
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 neural network layer that can be called on tensors
layer = nn.Linear(4, 3)

# Create prev_upper and prev_lower tensors
# These should be compatible with the layer's input dimension (4)
prev_upper = torch.randn(2, 4)
prev_lower = torch.randn(2, 4)

ARGS = {
    "layer": layer,
    "prev_upper": prev_upper,
    "prev_lower": prev_lower
}
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
dict_product Ran
ran; our contract draft was wrong, not the code
umd-huang-lab/WocaR-RL/WocaR-PPO/src/utils.py
code served (permissive licence) · get_code("35b6f17122388f57")
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 map. 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 itertools

# The function expects a dictionary where each value is a list of possible values
# It will create all combinations using itertools.product

d = {
    "learning_rate": [0.001, 0.01, 0.1],
    "batch_size": [16, 32],
    "optimizer": ["adam", "sgd"],
    "num_layers": [2, 3, 4]
}

ARGS = {"d": d}
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 map — a map output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a map 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
get_alg_name Ran
ran; our contract draft was wrong, not the code
romanbelaire/acoe-robust-rl/get_best_pickle.py
code served (permissive licence) · get_code("85bf3d86b586cab7")
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 str. 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 os

def get_alg_name(name):
    name = os.path.basename(os.path.dirname(name))
    if 'trpo' in name:
        return 'trpo'
    elif 'robust_ppo' in name:
        return 'robust_ppo'
    elif 'adv_sa_ppo' in name:
        return 'adv_sa_ppo'
    elif 'adv_ppo' in name:
        return 'adv_ppo'
    elif 'ppo' in name:
        return 'ppo'
    elif 'adv_pa_ppo' in name:
        return 'adv_pa_ppo'
    return 'unknown'

ARGS = {
    'name': '/path/to/ppo/model.pt'
}
Setup block drafted by
a language model, Claude Haiku 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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
get_alg_name Ran
ran; our contract draft was wrong, not the code
umd-huang-lab/WocaR-RL/WocaR-PPO/src/get_best_pickle.py
code served (permissive licence) · get_code("aa0592ec6641ad10")
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 str. 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 os
import tempfile

def get_alg_name(name):
    name = os.path.basename(os.path.dirname(name))
    if 'trpo' in name:
        return 'trpo'
    elif 'robust_ppo' in name:
        return 'robust_ppo'
    elif 'adv_sa_ppo' in name:
        return 'adv_sa_ppo'
    elif 'adv_ppo' in name:
        return 'adv_ppo'
    elif 'ppo' in name:
        return 'ppo'
    elif 'robust_q_ppo' in name:
        return 'robust_q_ppo'
    return 'unknown'

# Create temporary directory structure to test the function
temp_dir = tempfile.mkdtemp()
alg_dir = os.path.join(temp_dir, 'ppo_experiment')
os.makedirs(alg_dir, exist_ok=True)
test_file = os.path.join(alg_dir, 'checkpoint.pt')

ARGS = {
    'name': test_file
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
get_env_name Ran
ran; our contract draft was wrong, not the code
romanbelaire/acoe-robust-rl/get_best_pickle.py
code served (permissive licence) · get_code("35a892ade6c313d2")
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 str. 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

ARGS = {
    'name': 'humanoid-v4'
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
initial_bounds Ran
ran, violated the contract we drafted
umd-huang-lab/WocaR-RL/WocaR-DQN/RA-DQN/ibp.py
code served (permissive licence) · get_code("cfb1c3dd218b92f0")
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 5, 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

torch.manual_seed(0)

# x0 is a tensor of shape (b, c, h, w)
# The function performs simple arithmetic operations on it
x0 = torch.randn(2, 3, 4, 5)

# epsilon is a scalar value for the perturbation bounds
epsilon = 0.1

ARGS = {
    "x0": x0,
    "epsilon": 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 tuple, ndim 5, 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
iwt Ran
ran, honoured the contract we drafted
umd-huang-lab/WocaR-RL/WocaR-PPO/src/utils.py
code served (permissive licence) · get_code("942706632c22fc44")
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 list, ndim 1, dtype family int; 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 numpy as np

ARGS = {
    "start": 0,
    "end": 10,
    "interval": 2,
    "trials": 3
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family int — a list 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
process_frame Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
umd-huang-lab/WocaR-RL/WocaR-DQN/RA-DQN/environment.py
code served (permissive licence) · get_code("23ff92a17dc4fd23")
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 (1, 80, 80) 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

# Create a sample frame: height x width x channels (BGR)
# The function expects:
# - frame[crop1:crop2+160, :160] to work, so height must be > crop2+160
# - frame.mean(2) means 3 channels (color image)
frame = np.random.randint(0, 256, size=(400, 160, 3), dtype=np.uint8)

# Create conf dict with required keys
conf = {
    'crop1': 50,
    'crop2': 100,
    'dimension2': 80
}

ARGS = {
    'frame': frame,
    'conf': conf
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
cv2, numpy — 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 (1, 80, 80) — shape (1, 80, 80) 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
read_config Ran
ran; our contract draft was wrong, not the code
umd-huang-lab/WocaR-RL/WocaR-DQN/RA-DQN/utils.py
code served (permissive licence) · get_code("4000c95fa330f2ce")
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 dict. 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 json
import tempfile
import os

# Create a temporary JSON config file
temp_dir = tempfile.mkdtemp()
config_file_path = os.path.join(temp_dir, "config.json")

config_data = {
    "model": "test_model",
    "learning_rate": 0.001,
    "batch_size": 32,
    "epochs": 10,
    "layers": [64, 128, 256]
}

with open(config_file_path, 'w') as f:
    json.dump(config_data, f)

ARGS = {
    "file_path": config_file_path
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
weighted_bound Ran
ran; our contract draft was wrong, not the code
umd-huang-lab/WocaR-RL/WocaR-DQN/SA-DQN/models.py
code served (permissive licence) · get_code("eba320329ae9cb63")
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
import torch.nn.functional as F

torch.manual_seed(0)

# Create a small linear layer for testing
linear_layer = nn.Linear(4, 3)

# Create small tensors for prev_upper and prev_lower
# Shape: (batch=2, features=4) for linear, or (batch=2, channels=4, height=5, width=5) for conv2d
prev_upper_linear = torch.randn(2, 4)
prev_lower_linear = torch.randn(2, 4)

# Create a small Conv2d layer for testing
conv_layer = nn.Conv2d(in_channels=4, out_channels=3, kernel_size=3, stride=1, padding=1)

# Create small tensors for conv2d
prev_upper_conv = torch.randn(2, 4, 5, 5)
prev_lower_conv = torch.randn(2, 4, 5, 5)

# Test with linear layer
ARGS = {
    "layer": linear_layer,
    "prev_upper": prev_upper_linear,
    "prev_lower": prev_lower_linear,
}
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
atari_env Not yet run
unverified (harvested, no recorded run)
umd-huang-lab/WocaR-RL/WocaR-DQN/RA-DQN/environment.py
code served (permissive licence) · get_code("09c7359e9f493f7c")
How it ran

no invocation recorded.

record_game Not yet run
unverified (harvested, no recorded run)
umd-huang-lab/WocaR-RL/WocaR-DQN/RA-DQN/evaluate.py
code served (permissive licence) · get_code("3a204c610b328628")
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, 10 are also present in other papers whose code we hold (10 with at least one paper dated earlier, 1 the same month, 1 later) and 2 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
activation_bound 5 other papers
5 dated earlier
1907.09470 (2019-07)
Characterizing Attacks on Deep Reinforcement Learning
2008.01976 (2020-08)
Robust Deep Reinforcement Learning through Adversarial Loss
2111.06063 (2021-11)
On the Equivalence between Neural Network and Support Vector Machine
and 2 more not named here
read_config 5 other papers
4 dated earlier, 1 later
1809.00397 (2018-09)
Visual Transfer between Atari Games using Competitive Reinforcement Learning
2002.03519 (2020-02)
Self-Attentive Associative Memory
2008.01976 (2020-08)
Robust Deep Reinforcement Learning through Adversarial Loss
and 2 more not named here
dict_product 4 other papers
3 dated earlier, 1 the same month
2005.12729 (2020-05)
Implementation Matters in Deep Policy Gradients: A Case Study on PPO and TRPO
2009.10897 (2020-09)
Revisiting Design Choices in Proximal Policy Optimization
2302.06912 (2023-02)
Regret-Based Defense in Adversarial Reinforcement Learning
and 1 more not named here
initial_bounds 4 other papers
4 dated earlier
1907.09470 (2019-07)
Characterizing Attacks on Deep Reinforcement Learning
2008.01976 (2020-08)
Robust Deep Reinforcement Learning through Adversarial Loss
2111.06063 (2021-11)
On the Equivalence between Neural Network and Support Vector Machine
and 1 more not named here
weighted_bound 4 other papers
4 dated earlier
1907.09470 (2019-07)
Characterizing Attacks on Deep Reinforcement Learning
2008.01976 (2020-08)
Robust Deep Reinforcement Learning through Adversarial Loss
2402.02165 (2024-02)
Towards Optimal Adversarial Robust Q-learning with Bellman Infinity-error
and 1 more not named here
iwt 3 other papers
3 dated earlier
2005.12729 (2020-05)
Implementation Matters in Deep Policy Gradients: A Case Study on PPO and TRPO
2009.10897 (2020-09)
Revisiting Design Choices in Proximal Policy Optimization
2302.06912 (2023-02)
Regret-Based Defense in Adversarial Reinforcement Learning
atari_env 1 other paper
1 dated earlier
2008.01976 (2020-08)
Robust Deep Reinforcement Learning through Adversarial Loss
get_alg_name 1 other paper
1 dated earlier
2302.06912 (2023-02)
Regret-Based Defense in Adversarial Reinforcement Learning
get_env_name 1 other paper
1 dated earlier
2302.06912 (2023-02)
Regret-Based Defense in Adversarial Reinforcement Learning
process_frame 1 other paper
1 dated earlier
2008.01976 (2020-08)
Robust Deep Reinforcement Learning through Adversarial Loss

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

Deep Reinforcement Learning (DRL) policies are highly susceptible to adversarial noise in observations, which poses significant risks in safety-critical scenarios. The challenge inherent to adversarial perturbations is that by altering the information observed by the agent, the state becomes only partially observable. Existing approaches address this by either enforcing consistent actions across nearby states or maximizing the worst-case value within adversarially perturbed observations. However, the former suffers from performance degradation when attacks succeed, while the latter tends to be overly conservative, leading to suboptimal performance in benign settings. We hypothesize that these limitations stem from their failing to account for partial observability directly. To this end, we introduce a novel objective called Adversarial Counterfactual Error (ACoE), defined on the beliefs about the true state and balancing value optimization with robustness. To make ACoE scalable in model-free settings, we propose the theoretically-grounded surrogate objective Cumulative-ACoE (C-ACoE). Our empirical evaluations on standard benchmarks (MuJoCo, Atari, and Highway) demonstrate that our method significantly outperforms current state-of-the-art approaches for addressing adversarial RL challenges, offering a promising direction for improving robustness in DRL under adversarial conditions. Our code is available at https://github.com/romanbelaire/acoe-robust-rl.

For agents

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

get_harvested_code_for_paper("2406.04724")
get_code_for_paper("2406.04724")
have("2406.04724")

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

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

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

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

Connect an agent — have() is free.