SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2005.13239 · NeurIPS · 2020

MOPO: Model-based Offline Policy Optimization

U Berkeley, Tianhe Yu, Sergey Levine, Chelsea Finn, Stefano Ermon, Tengyu Ma, Lantao Yu, Garrett Thomas, James Zou

arXiv · PDF · Open in the Atlas

Code that ran

3 of 8 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (1 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 2 have no contract verdict; 1 failure of our instrument; 5 no recorded run), measured 2026-11-21; 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/2005.13239.json · badge: /api/ran/2005.13239.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
yihaosun1124/OfflineRL-Kit community
Papers with Code archive
2 ran · 1 no recorded run
junming-yang/mopo port (classifier label)
classifier basis: classifier_2025
1 ran · 1 no recorded run
Yihao-Sun/pytorch-mopo community
Papers with Code archive
0 ran · 2 no recorded run
runamu/compositional-conservatism community
Papers with Code archive
0 ran · 1 no recorded run
FunctionStatusWhere it lives
BaseDynamics Ran
ran on a synthesized input · constructed an object; no result was computed
yihaosun1124/OfflineRL-Kit/offlinerlkit/policy/model_based/mopo.py
code served (permissive licence) · get_code("0367ac63f92bed11")
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, BaseDynamics: 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 numpy as np
import torch
import torch.nn as nn
from typing import Dict, Union, Tuple

torch.manual_seed(0)

# Create a minimal nn.Module for the model
class MinimalDynamicsModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(7, 4)  # 3 obs + 4 action -> 4 output
    
    def forward(self, x):
        return self.linear(x)

# Instantiate the model
model = MinimalDynamicsModel()

# Create an optimizer
optim = torch.optim.Adam(model.parameters(), lr=0.001)

# Define ARGS dictionary with all required parameters
ARGS = {
    "model": model,
    "optim": optim
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type BaseDynamics — 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 BaseDynamics 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
SACPolicy Ran
ran on a synthesized input
yihaosun1124/OfflineRL-Kit/offlinerlkit/policy/model_based/mopo.py
code served (permissive licence) · get_code("b3d37324c880e711")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) 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 torch
import torch.nn as nn
import numpy as np
from torch.distributions import Normal

# Define dimensions
obs_dim = 5
action_dim = 3
hidden_dim = 8
batch_size = 2

# Create simple actor network that outputs a distribution
class SimpleActor(nn.Module):
    def __init__(self, obs_dim, action_dim, hidden_dim):
        super().__init__()
        self.net = nn.Sequential(
            nn.Linear(obs_dim, hidden_dim),
            nn.ReLU(),
            nn.Linear(hidden_dim, action_dim * 2)  # mean and log_std
        )
        self.action_dim = action_dim
    
    def forward(self, obs):
        output = self.net(obs)
        mean = output[..., :self.action_dim]
        log_std = output[..., self.action_dim:]
        log_std = torch.clamp(log_std, -20, 2)
        return TanhNormal(mean, log_std.exp())

class TanhNormal:
    def __init__(self, mean, std):
        self.mean = mean
        self.std = std
        self.normal = Normal(mean, std)
    
    def rsample(self):
        raw_action = self.normal.rsample()
        squashed_action = torch.tanh(raw_action)
        return squashed_action, raw_action
    
    def mode(self):
        raw_action = self.mean
        squashed_action = torch.tanh(raw_action)
        return squashed_action, raw_action
    
    def log_prob(self, squashed_action, raw_action):
        log_prob = self.normal.log_prob(raw_action).sum(dim=-1, keepdim=True)
        log_prob -= torch.log(1 - squashed_action.pow(2) + 1e-6).sum(dim=-1, keepdim=True)
        return log_prob

# Create simple critic networks
class SimpleCritic(nn.Module):
    def __init__(self, obs_dim, action_dim, hidden_dim):
        super().__init__()
        self.net = nn.Sequential(
            nn.Linear(obs_dim + action_dim, hidden_dim),
            nn.ReLU(),
            nn.Linear(hidden_dim, 1)
        )
    
    def forward(self, obs, action):
        return self.net(torch.cat([obs, action], dim=-1))

# Create networks
actor = SimpleActor(obs_dim, action_dim, hidden_dim)
critic1 = SimpleCritic(obs_dim, action_dim, hidden_dim)
critic2 = SimpleCritic(obs_dim, action_dim, hidden_dim)

# Create optimizers
actor_optim = torch.optim.Adam(actor.parameters(), lr=3e-4)
critic1_optim = torch.optim.Adam(critic1.parameters(), lr=3e-4)
critic2_optim = torch.optim.Adam(critic2.parameters(), lr=3e-4)

# Setup for auto alpha
target_entropy = -float(action_dim)
log_alpha = torch.zeros(1, requires_grad=True)
alpha_optim = torch.optim.Adam([log_alpha], lr=3e-4)

INIT_ARGS = {
    'actor': actor,
    'critic1': critic1,
    'critic2': critic2,
    'actor_optim': actor_optim,
    'critic1_optim': critic1_optim,
    'critic2_optim': critic2_optim,
    'tau': 0.005,
    'gamma': 0.99,
    'alpha': (target_entropy, log_alpha, alpha_optim)
}

# Create batch data for learn method
batch = {
    'observations': torch.randn(batch_size, obs_dim),
    'actions': torch.randn(batch_size, action_dim),
    'next_observations': torch.randn(batch_size, obs_dim),
    'rewards': torch.randn(batch_size, 1),
    'terminals': torch.zeros(batch_size, 1)
}

ARGS = {
    'batch': batch
}

METHOD = 'learn'
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
numpy, torch — 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
dict_batch_generator Ran
ran; our contract draft was wrong, not the code
junming-yang/mopo/algo/mopo.py
code served (permissive licence) · get_code("9bfce911836d13d9")
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 generator. 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 numpy as np

# Create sample data as a dictionary with numpy arrays
# The function expects data[key] to be indexable with numpy indices
data = {
    'features': np.random.randn(10, 4),  # 10 samples, 4 features
    'labels': np.random.randint(0, 2, 10),  # 10 labels
    'ids': np.arange(10)  # 10 ids
}

batch_size = 3

keys = None  # Will use all keys from data

ARGS = {
    'data': data,
    'batch_size': batch_size,
    'keys': keys
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type generator — a generator output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a generator 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
FakeEnv Not yet run
unverified (harvested, no recorded run)
Yihao-Sun/pytorch-mopo/mopo.py
code served (permissive licence) · get_code("905ff707fa717537")
How it ran

no invocation recorded.

MOPO Not yet run
unverified (harvested, no recorded run)
junming-yang/mopo/algo/mopo.py
code served (permissive licence) · get_code("4915612bb67c4977")
How it ran

no invocation recorded.

MOPO Not yet run
unverified (harvested, no recorded run)
Yihao-Sun/pytorch-mopo/mopo.py
code served (permissive licence) · get_code("29dd6b4e1d20ae33")
How it ran

no invocation recorded.

MOPOPolicy Not yet run
unverified (harvested, no recorded run)
yihaosun1124/OfflineRL-Kit/offlinerlkit/policy/model_based/mopo.py
code served (permissive licence) · get_code("cee64d8d029d6485")
How it ran

no invocation recorded.

train Not yet run
unverified (harvested, no recorded run)
runamu/compositional-conservatism/run_example/run_mopo.py
code served (permissive licence) · get_code("2c8a2717c213a768")
How it ran

no invocation recorded.

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 distinct functions with an identity, 4 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 4 later) and 4 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
BaseDynamics
brick of this paper's assembly: helper
5 other papers
5 later · 3 only as an assembly brick
2102.08363 (2021-02)
COMBO: Conservative Offline Model-Based Policy Optimization
2204.12581 (2022-04)
RAMBO-RL: Robust Adversarial Model-Based Offline Reinforcement Learning
2504.11944 (2025-04)
VIPO: Value Function Inconsistency Penalized Offline Reinforcement Learning
and 2 more not named here
SACPolicy
brick of this paper's assembly: helper
5 other papers
5 later · 3 only as an assembly brick
2006.04779 (2020-06)
Conservative Q-Learning for Offline Reinforcement Learning
2102.08363 (2021-02)
COMBO: Conservative Offline Model-Based Policy Optimization
2204.12581 (2022-04)
RAMBO-RL: Robust Adversarial Model-Based Offline Reinforcement Learning
and 2 more not named here
MOPOPolicy
brick of this paper's assembly: entry
2 other papers
2 later · 1 only as an assembly brick
2204.12581 (2022-04)
RAMBO-RL: Robust Adversarial Model-Based Offline Reinforcement Learning
2603.08118 (2026-03)
Model-based Offline RL via Robust Value-Aware Model Learning with Implicitly Differentiable Adaptive Weighting
FakeEnv
brick of this paper's assembly: model
1 other paper
1 later
2206.07989 (2022-06)
Double Check Your State Before Trusting It: Confidence-Aware Bidirectional Offline Model-Based Imagination

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

Repositories linked to this paper

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

Abstract

Offline reinforcement learning (RL) refers to the problem of learning policies entirely from a large batch of previously collected data. This problem setting offers the promise of utilizing such datasets to acquire policies without any costly or dangerous active exploration. However, it is also challenging, due to the distributional shift between the offline training data and those states visited by the learned policy. Despite significant recent progress, the most successful prior methods are model-free and constrain the policy to the support of data, precluding generalization to unseen states. In this paper, we first observe that an existing model-based RL algorithm already produces significant gains in the offline setting compared to model-free approaches. However, standard model-based RL methods, designed for the online setting, do not provide an explicit mechanism to avoid the offline setting's distributional shift issue. Instead, we propose to modify the existing model-based RL methods by applying them with rewards artificially penalized by the uncertainty of the dynamics. We theoretically show that the algorithm maximizes a lower bound of the policy's return under the true MDP. We also characterize the trade-off between the gain and risk of leaving the support of the batch data. Our algorithm, Model-based Offline Policy Optimization (MOPO), outperforms standard model-based RL algorithms and prior state-of-the-art model-free offline RL algorithms on existing offline RL benchmarks and two challenging continuous control tasks that require generalizing from data collected for a different task. * equal contribution. † equal advising. Orders randomized. 34th Conference on Neural Information Processing Systems (NeurIPS 2020),

For agents

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

get_harvested_code_for_paper("2005.13239")
get_code_for_paper("2005.13239")
have("2005.13239")

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

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

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

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

Connect an agent — have() is free.