A pytorch-based deep reinforcement learning package
Project description
Python-DRL
A pytorch-based deep reinforcement learning package. At present, I have implemented the following reinforcement learning algorithms: Deep Q-Network (DQN), Policy Gradient (PG), Proximal Policy Optimization (PPO), Deep Deterministic Policy Gradient (DDPG), Twin Delayed DDPG (TD3), and Soft Actor-Critic (SAC).
Dependencies
numpy~=1.23.0
torch>=2.0.1
gym~=0.26.2
opencv-python>=4.5.5.62
pygame~=2.5.2
Supported Python Versions
3.8
3.9
3.10
Install
pip install Python-DRL
Basic Usage Examples With Gym
python ./examples/cartpole-demo.py -m [train/test] -t [DQN/PPO/PG]
python ./examples/pendulum-demo.py -m [train/test] -t [DDPG/TD3/SAC]
Note that examples
will not be installed by pip install Python-DRL
.
Detailed Usage Guide
DQN
from DRL.dqn import DQN
DQN(n_states, n_actions, hidden_dim=64, critic_lr=1e-3, gamma=0.9, explore_intensity=100, replay_capacity=1000, replay_batch_size=32, target_update_freq=20, is_double_dqn=True, is_load=False, critic_path_name="dqn_critic_net.pkl", is_train=True)
PPO
from DRL.ppo import PPO
PPO(n_states, n_actions, hidden_dim=64, actor_lr=1e-4, critic_lr=1e-3, gamma=0.99, eps_clip=0.2, learn_epochs=20, is_load=False, actor_path_name="ppo_actor_net.pkl", critic_path_name="ppo_critic_net.pkl", is_train=True)
PG
from DRL.pg import PG
PG(n_states, n_actions, hidden_dim=64, actor_lr=1e-3, gamma=0.99, is_load=False, actor_path_name="pg_actor_net.pkl", is_train=True)
DDPG
from DRL.ddpg import DDPG
DDPG(n_states, n_actions, max_action, hidden_dim=300, actor_lr=1e-4, critic_lr=1e-3, gamma=0.99, tau=0.0005, learn_epochs=200, replay_capacity=1000000, replay_batch_size=100, is_load=False, actor_path_name="ddpg_actor_net.pkl", critic_path_name="ddpg_critic_net.pkl", is_train=True)
TD3
from DRL.td3 import TD3
TD3(n_states, n_actions, max_action, hidden_dim=300, actor_lr=1e-4, critic_lr=1e-3, gamma=0.99, tau=0.0005, learn_epochs=200, replay_capacity=1000000, replay_batch_size=100, is_load=False, actor_path_name="td3_actor_net.pkl", critic_path_name="td3_critic_net.pkl", is_train=True)
SAC
from DRL.sac import SAC
SAC(n_states, n_actions, max_action, hidden_dim=300, actor_lr=3e-3, critic_lr=3e-3, alpha_lr=3e-3, alpha=0.5, gamma=0.99, tau=0.005, replay_capacity=10000, replay_batch_size=100, automatic_entropy_tuning=True, is_load=False, actor_path_name="sac_actor_net.pkl", is_train=True)
Updates Log
- 1.0.0
- implemented DQN, PG, PPO, DDPG, TD3, and SAC (missing pygame)
- 1.0.1
- add pygame dependency
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Python-DRL-1.0.1.tar.gz
(9.2 kB
view details)
Built Distribution
File details
Details for the file Python-DRL-1.0.1.tar.gz
.
File metadata
- Download URL: Python-DRL-1.0.1.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fff0eaa9ad7b54b6439044b11b683e1971d61b9a5130f2a316dee9d2f77346e1 |
|
MD5 | 6096f17706ccb15e4bfe240bec4cace3 |
|
BLAKE2b-256 | 5a1413781939eb1a8e1a229c1724c7a6f24c30aeb550fab95d9e16211c1c8c93 |
File details
Details for the file Python_DRL-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: Python_DRL-1.0.1-py3-none-any.whl
- Upload date:
- Size: 16.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e692255f1032a0f9ea62906dfcb13aed5a8c3fc0fb84e68f9fe20e377761aa44 |
|
MD5 | deb383de311047cc56504ae7f60fe298 |
|
BLAKE2b-256 | a1b64dea9c0d6679ffa33618cf61ac81b47405f9b9a817b5fee8e40fda4717cd |