SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1502.05477 · 2015

Trust Region Policy Optimization

Michael Jordan, John Schulman, Philipp Moritz

arXiv · PDF · Open in the Atlas

Code that ran

7 of 17 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (2 of them constructed an object rather than computing a result; 2 honoured the contract we drafted, 0 violated it and 4 have no contract verdict; 1 failure of our instrument; 10 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/1502.05477.json · badge: /api/ran/1502.05477.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
pat-coady/trpo community
Papers with Code archive
3 ran · 1 no recorded run
spideralessio/TRPO-Tensorflow2 community
Papers with Code archive
2 ran · 2 no recorded run
copy not recorded community
not in the paper's declared repositories
1 ran · 1 no recorded run
ifestus/rl community
Papers with Code archive
1 ran · 0 no recorded run
Khrylx/PyTorch-RL community
Papers with Code archive
0 ran · 2 no recorded run
ikostrikov/pytorch-trpo community
Papers with Code archive
0 ran · 2 no recorded run
magnusja/ppo community
Papers with Code archive
0 ran · 1 no recorded run
tensorlayer/RLzoo community
Papers with Code archive
0 ran · 1 no recorded run
FunctionStatusWhere it lives
KLEntropy Ran
ran on a synthesized input
pat-coady/trpo/trpo/policy.py
code served (permissive licence) · get_code("21087806cd98f0eb")
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 list, ndim 3, 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 tensorflow as tf
import tensorflow.keras.backend as K
from tensorflow.keras.layers import Dense, Layer
import numpy as np

class KLEntropy(Layer):
    """
    Layer calculates:
        1. KL divergence between old and new distributions
        2. Entropy of present policy

    https://en.wikipedia.org/wiki/Multivariate_normal_distribution#Kullback.E2.80.93Leibler_divergence
    https://en.wikipedia.org/wiki/Multivariate_normal_distribution#Entropy
    """

    def __init__(self, **kwargs):
        super(KLEntropy, self).__init__(**kwargs)
        self.act_dim = None

    def build(self, input_shape):
        self.act_dim = input_shape[0][1]

    def call(self, inputs, **kwargs):
        old_means, old_logvars, new_means, new_logvars = inputs
        log_det_cov_old = K.sum(old_logvars, axis=-1, keepdims=True)
        log_det_cov_new = K.sum(new_logvars, axis=-1, keepdims=True)
        trace_old_new = K.sum(K.exp(old_logvars - new_logvars), axis=-1, keepdims=True)
        kl = 0.5 * (log_det_cov_new - log_det_cov_old + trace_old_new + K.sum(K.square(new_means - old_means) / K.exp(new_logvars), axis=-1, keepdims=True) - np.float32(self.act_dim))
        entropy = 0.5 * (np.float32(self.act_dim) * (np.log(2 * np.pi) + 1.0) + K.sum(new_logvars, axis=-1, keepdims=True))
        return [kl, entropy]


INIT_ARGS = {}

ARGS = {
    'inputs': [
        tf.constant(np.random.randn(2, 4).astype(np.float32)),
        tf.constant(np.random.randn(2, 4).astype(np.float32)),
        tf.constant(np.random.randn(2, 4).astype(np.float32)),
        tf.constant(np.random.randn(2, 4).astype(np.float32))
    ]
}

METHOD = 'call'

if __name__ == '__main__':
    layer = KLEntropy(**INIT_ARGS)
    result = layer(**ARGS)
    print("KL divergence shape:", result[0].shape)
    print("Entropy shape:", result[1].shape)
    print("Result:", result)
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
numpy, tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 3, dtype family float — 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
LogProb Ran
ran on a synthesized input
pat-coady/trpo/trpo/policy.py
code served (permissive licence) · get_code("cb1881154c084926")
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 EagerTensor, 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.

import tensorflow as tf
import tensorflow.keras.backend as K
from tensorflow.keras.layers import Dense, Layer

class LogProb(Layer):
    """Layer calculates log probabilities of a batch of actions."""

    def __init__(self, **kwargs):
        super(LogProb, self).__init__(**kwargs)

    def call(self, inputs, **kwargs):
        actions, act_means, act_logvars = inputs
        logp = -0.5 * K.sum(act_logvars, axis=-1, keepdims=True)
        logp += -0.5 * K.sum(K.square(actions - act_means) / K.exp(act_logvars), axis=-1, keepdims=True)
        return logp


INIT_ARGS = {}

batch_size = 2
action_dim = 4

actions = tf.random.normal((batch_size, action_dim))
act_means = tf.random.normal((batch_size, action_dim))
act_logvars = tf.random.normal((batch_size, action_dim))

ARGS = {
    'inputs': [actions, act_means, act_logvars]
}

if __name__ == '__main__':
    layer = LogProb(**INIT_ARGS)
    output = layer(**ARGS)
    print("Output shape:", output.shape)
    print("Output:", output)
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type EagerTensor, ndim 2, dtype family float — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
PolicyNN Ran
ran on a synthesized input · constructed an object; no result was computed
pat-coady/trpo/trpo/policy.py
code served (permissive licence) · get_code("adb1b2f8460af76c")
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, PolicyNN: 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 tensorflow as tf
import tensorflow.keras.backend as K
from tensorflow.keras.layers import Dense, Layer
import numpy as np

ARGS = {
    'obs_dim': 4,
    'act_dim': 3,
    'hid1_mult': 2,
    'init_logvar': -1.0,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type PolicyNN — 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 PolicyNN 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
TRPOAgent Ran
ran on a synthesized input · constructed an object; no result was computed
ifestus/rl/policy_agents.py
pointer only (licence: NONE) · get_code("68f53fd02ecf2c67")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, ifestus/rl when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

conjugate_gradients Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
this paper's copy was not recorded; identical code first harvested from Stanford-ILIAD/Learn-Imperfect-Varying-Dynamics
pointer only · get_code("918891131c62a121")
How it ran

The body of this sample is withheld: this paper's copy of the code was not recorded (its link names no repository or source path), so no licence was read for it. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

flatgrad Ran
ran, honoured the contract we drafted
spideralessio/TRPO-Tensorflow2/TRPO.py
pointer only (licence: NONE) · get_code("624753be66ae25df")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, spideralessio/TRPO-Tensorflow2 when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

flatvars Ran
ran, honoured the contract we drafted
spideralessio/TRPO-Tensorflow2/TRPO.py
pointer only (licence: NONE) · get_code("7c5c823b328af93a")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, spideralessio/TRPO-Tensorflow2 when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

Policy Not yet run
unverified (harvested, no recorded run)
magnusja/ppo/src/policy.py
code served (permissive licence) · get_code("b11d0213b416df62")
How it ran

no invocation recorded.

TRPO Not yet run
unverified (harvested, no recorded run)
spideralessio/TRPO-Tensorflow2/TRPO.py
pointer only (licence: NONE) · get_code("bc789c354e38ee20")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, spideralessio/TRPO-Tensorflow2 when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

TRPO Not yet run
unverified (harvested, no recorded run)
pat-coady/trpo/trpo/policy.py
code served (permissive licence) · get_code("f51bd581b9a86ab1")
How it ran

no invocation recorded.

TRPO Not yet run
unverified (harvested, no recorded run)
tensorlayer/RLzoo/rlzoo/algorithms/trpo/trpo.py
code served (permissive licence) · get_code("84ac3feb93cdf5c7")
How it ran

no invocation recorded.

assign_vars Not yet run
unverified (harvested, no recorded run)
spideralessio/TRPO-Tensorflow2/TRPO.py
pointer only (licence: NONE) · get_code("16b584c62bee3a78")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, spideralessio/TRPO-Tensorflow2 when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

conjugate_gradients Not yet run
unverified (harvested, no recorded run)
Khrylx/PyTorch-RL/core/trpo.py
code served (permissive licence) · get_code("8946170b041be61b")
How it ran

no invocation recorded.

line_search Not yet run
unverified (harvested, no recorded run)
this paper's copy was not recorded; identical code first harvested from sapanachaudhary/pytorch-cpo
pointer only · get_code("f7c68d288ffc351b")
How it ran

The body of this sample is withheld: this paper's copy of the code was not recorded (its link names no repository or source path), so no licence was read for it. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

linesearch Not yet run
unverified (harvested, no recorded run)
ikostrikov/pytorch-trpo/trpo.py
code served (permissive licence) · get_code("6b18e6942fb60f72")
How it ran

no invocation recorded.

trpo_step Not yet run
unverified (harvested, no recorded run)
ikostrikov/pytorch-trpo/trpo.py
code served (permissive licence) · get_code("6bcf14c615d2dc3a")
How it ran

no invocation recorded.

trpo_step Not yet run
unverified (harvested, no recorded run)
Khrylx/PyTorch-RL/core/trpo.py
code served (permissive licence) · get_code("52129aa1d9bff078")
How it ran

no invocation recorded.

Also present in other papers' code

Of 17 samples lifted from this paper's linked repositories, 17 carry a function identity and 0 do not. Of the 17 distinct functions with an identity, 3 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 3 later) and 14 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
conjugate_gradients
brick of this paper's assembly: helper
2 other papers
2 later
2003.04108 (2020-03)
Stable Policy Optimization via Off-Policy Divergence Regularization
2103.05910 (2021-03)
Learning from Imperfect Demonstrations from Agents with Varying Dynamics
conjugate_gradients
brick of this paper's assembly: helper
1 other paper
1 later
1705.10528 (2017-05)
Constrained Policy Optimization
line_search
brick of this paper's assembly: update_rule
1 other paper
1 later
1705.10528 (2017-05)
Constrained Policy Optimization

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

We describe an iterative procedure for optimizing policies, with guaranteed monotonic improvement. By making several approximations to the theoretically-justified procedure, we develop a practical algorithm, called Trust Region Policy Optimization (TRPO). This algorithm is similar to natural policy gradient methods and is effective for optimizing large nonlinear policies such as neural networks. Our experiments demonstrate its robust performance on a wide variety of tasks: learning simulated robotic swimming, hopping, and walking gaits; and playing Atari games using images of the screen as input. Despite its approximations that deviate from the theory, TRPO tends to give monotonic improvement, with little tuning of hyperparameters.

For agents

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

get_harvested_code_for_paper("1502.05477")
get_code_for_paper("1502.05477")
have("1502.05477")

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

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

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

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

Connect an agent — have() is free.