SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2303.13971 · ICLR · 2023

Optimal Transport for Offline Imitation Learning

Marc Deisenroth, Edward Grefenstette, Samuel Cohen, Yicheng Luo, Zhengyao Jiang

arXiv · PDF · Open in the Atlas

Code that ran

5 of 5 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; 3 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 2 failures of our instrument; 0 no recorded run); 1 of them was also run on the host, not in the jail, by the peer-agreement lane that set its level, 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/2303.13971.json · badge: /api/ran/2303.13971.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
ethanluoyc/optimal_transport_reward canonical (classifier label)
classifier basis: classifier_2025
5 ran · 0 no recorded run
FunctionStatusWhere it lives
squashing_linear Ran
ran, honoured the contract we drafted
ethanluoyc/optimal_transport_reward/otr/agents/otil/rewarder.py
code served (permissive licence) · get_code("a34685e3282279e7")
How it ran

Ran in Syntology's jail on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) 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. The comparison behind this sample's level is a different run: the peer-agreement lane ran it again on the host, not in the jail (report dated 2026-09-05T01:17:21Z). 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)

# Create a small tensor for rewards
# The function simply multiplies rewards by alpha, so rewards can be any numeric tensor
rewards = torch.randn(2, 4)

# Create the ARGS dictionary with all parameters
ARGS = {
    "rewards": rewards,
    "alpha": 10.0,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 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
aggregate_mean Ran
ran, honoured the contract we drafted
ethanluoyc/optimal_transport_reward/otr/agents/otil/rewarder.py
code served (permissive licence) · get_code("486770c9e1d0c8e0")
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 ArrayImpl, ndim 1, dtype family float, shape (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 jax.numpy as jnp
import numpy as np

# Create sample rewards from multiple expert demonstrations
# Shape: (num_experts, reward_dim)
# Using distinct sizes: 3 experts, 4 reward dimensions
rewards = jnp.array([
    [1.0, 2.0, 3.0, 4.0],
    [2.0, 3.0, 4.0, 5.0],
    [3.0, 4.0, 5.0, 6.0]
])

ARGS = {
    "rewards": rewards
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
jax, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ArrayImpl, ndim 1, dtype family float, shape (4,) — shape (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
aggregate_top_k Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
ethanluoyc/optimal_transport_reward/otr/agents/otil/rewarder.py
code served (permissive licence) · get_code("50516bfd3676382c")
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 ArrayImpl, ndim 1, dtype family float, shape (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 jax
import jax.numpy as jnp

# Create sample rewards tensor
# Shape: (num_demos, reward_dim)
# Using distinct sizes: 5 demos, 3 reward dimensions
rewards = jnp.array([
    [1.0, 2.0, 3.0],
    [4.0, 5.0, 6.0],
    [0.5, 1.5, 2.5],
    [2.0, 3.0, 4.0],
    [3.5, 4.5, 5.5]
])

ARGS = {
    "rewards": rewards,
    "k": 2
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
jax — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ArrayImpl, ndim 1, dtype family float, shape (3,) — shape (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
compute_iql_reward_scale Ran
ran, honoured the contract we drafted
ethanluoyc/optimal_transport_reward/otr/train_offline.py
code served (permissive licence) · get_code("e4cade61dd81ce21")
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 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 numpy as np

class Step:
    def __init__(self, reward):
        self.reward = reward

class Trajectory:
    def __init__(self, steps):
        self.steps = steps
    
    def __iter__(self):
        return iter(self.steps)

# Create trajectories with different total rewards
traj1 = Trajectory([Step(1.0), Step(2.0), Step(3.0)])  # total: 6.0
traj2 = Trajectory([Step(5.0), Step(10.0), Step(15.0)])  # total: 30.0
traj3 = Trajectory([Step(2.0), Step(3.0), Step(4.0)])  # total: 9.0

trajs = [traj1, traj2, traj3]

ARGS = {
    "trajs": trajs
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, 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
relabel_rewards Ran
ran; our contract draft was wrong, not the code
ethanluoyc/optimal_transport_reward/otr/train_offline.py
code served (permissive licence) · get_code("3b557f04514de244")
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 list. 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 collections import namedtuple

torch.manual_seed(0)

# Define a simple transition namedtuple
Transition = namedtuple('Transition', ['state', 'action', 'next_state', 'reward', 'done'])

# Create a minimal rewarder class that implements compute_offline_rewards
class SimpleRewarder(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 1)
    
    def compute_offline_rewards(self, trajectory):
        # trajectory is a list of Transition objects
        # Extract states and compute rewards
        states = torch.stack([t.state for t in trajectory])
        rewards = self.linear(states).squeeze(-1)
        return rewards

# Create rewarder instance
rewarder = SimpleRewarder()

# Create a small trajectory with 2 transitions
trajectory = [
    Transition(
        state=torch.randn(4),
        action=torch.tensor(0),
        next_state=torch.randn(4),
        reward=torch.tensor(1.0),
        done=False
    ),
    Transition(
        state=torch.randn(4),
        action=torch.tensor(1),
        next_state=torch.randn(4),
        reward=torch.tensor(0.5),
        done=True
    )
]

ARGS = {
    'rewarder': rewarder,
    'trajectory': trajectory
}
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 list — a list 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

Also present in other papers' code

Of 5 samples lifted from this paper's linked repositories, 5 carry a function identity and 0 do not. Of the 5 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 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.

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

With the advent of large datasets, offline reinforcement learning (RL) is a promising framework for learning good decision-making policies without the need to interact with the real environment. However, offline RL requires the dataset to be reward-annotated, which presents practical challenges when reward engineering is difficult or when obtaining reward annotations is labor-intensive. In this paper, we introduce Optimal Transport Reward labeling (OTR), an algorithm that assigns rewards to offline trajectories, with a few high-quality demonstrations. OTR's key idea is to use optimal transport to compute an optimal alignment between an unlabeled trajectory in the dataset and an expert demonstration to obtain a similarity measure that can be interpreted as a reward, which can then be used by an offline RL algorithm to learn the policy. OTR is easy to implement and computationally efficient. On D4RL benchmarks, we show that OTR with a single demonstration can consistently match the performance of offline RL with ground-truth rewards 1 .

For agents

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

get_harvested_code_for_paper("2303.13971")
get_code_for_paper("2303.13971")
have("2303.13971")

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

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

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

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

Connect an agent — have() is free.