Skip to main content

Reinforcement Learning Replications is a set of Pytorch implementations of reinforcement learning algorithms.

Project description

Reinforcement Learning Replications

Reinforcement Learning Replications is a set of Pytorch implementations of reinforcement learning algorithms.

Features

  • Implement Algorithms
    • Vanilla Policy Gradient (VPG)
    • Trust Region Policy Optimization (TRPO)
    • Proximal Policy Optimization (PPO)
    • Deep Deterministic Policy Gradient (DDPG)
    • Twin Delayed DDPG (TD3)
  • Use Python standard logging library
  • Support TensorBoard

Benchmarks

You can check the benchmark result here.

This benchmark is conducted based on the Benchmarks for Spinning Up Implementations.

All experiments were run for 3 random seeds each. All the details such as tensorboard and experiment logs, training scripts and trained models are stored in the benchmarks folder.

Example Code

Here is the code of training PPO on CartPole-v1 environment. You can run with this Google Colab notebook.

import gymnasium as gym
import torch
import torch.nn as nn

from rl_replicas.algorithms import PPO
from rl_replicas.networks import MLP
from rl_replicas.policies import CategoricalPolicy
from rl_replicas.samplers import BatchSampler
from rl_replicas.value_function import ValueFunction

env_name = "CartPole-v1"
output_dir = "/content/ppo"
num_epochs = 80
seed = 0

network_hidden_sizes = [64, 64]
policy_learning_rate = 3e-4
value_function_learning_rate = 1e-3

env = gym.make(env_name)
env.action_space.seed(seed)

observation_size: int = env.observation_space.shape[0]
action_size: int = env.action_space.n

policy_network: nn.Module = MLP(
    sizes=[observation_size] + network_hidden_sizes + [action_size]
)

value_function_network: nn.Module = MLP(
    sizes=[observation_size] + network_hidden_sizes + [1]
)

model: PPO = PPO(
    CategoricalPolicy(
        network=policy_network,
        optimizer=torch.optim.Adam(policy_network.parameters(), lr=3e-4),
    ),
    ValueFunction(
        network=value_function_network,
        optimizer=torch.optim.Adam(value_function_network.parameters(), lr=1e-3),
    ),
    env,
    BatchSampler(env, seed),
)

model.learn(num_epochs=num_epochs, output_dir=output_dir)

Contributing

All contributions are welcome.

Release Flow

  1. Create a release branch.
  2. A pull request from the release branch to the main branch has the following:
    • Change logs in the body.
    • The release label.
    • Commit that bumps up the version in VERSION.
  3. Once the pull request is ready, merge the pull request. The CI will upload the package and create the release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rl_replicas-0.0.7.tar.gz (21.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rl_replicas-0.0.7-py3-none-any.whl (33.5 kB view details)

Uploaded Python 3

File details

Details for the file rl_replicas-0.0.7.tar.gz.

File metadata

  • Download URL: rl_replicas-0.0.7.tar.gz
  • Upload date:
  • Size: 21.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for rl_replicas-0.0.7.tar.gz
Algorithm Hash digest
SHA256 03e9b89649b0cfee96fd1f6ce1f41c42405146ec4e13744fc70a9b89d27a0073
MD5 ccbf4c9abf9d468ca172bee293144dd1
BLAKE2b-256 517a61ce67295bd8a0b0abbc50f9094da1f44802d6999858eaabf61132ee783d

See more details on using hashes here.

File details

Details for the file rl_replicas-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: rl_replicas-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 33.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for rl_replicas-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 e93f4df1ec6fc67add85ac84887ba4027862e0cf0c19c27968323765a05a3e12
MD5 68844c526e237ad2ada265f17e64b7b9
BLAKE2b-256 2593c887c888d6a5ccfa0e9f1fc4056fbf920853ac6b3906a1ad3baf4478c28a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page