A clean Pytorch implementation of DDPG on continuous action space. Here is the result (all the experiments are trained with same hyperparameters):
Pendulum | LunarLanderContinuous |
---|---|
Note that DDPG is notoriously susceptible to hyperparameters and thus is unstable sometimes. We strongly recommend you use its refinement TD3. Other RL algorithms by Pytorch can be found here.
gymnasium==0.29.1
numpy==1.26.1
pytorch==2.1.0
python==3.11.5
python main.py
where the default enviroment is 'Pendulum'.
python main.py --EnvIdex 0 --render True --Loadmodel True --ModelIdex 100
which will render the 'Pendulum'.
If you want to train on different enviroments, just run
python main.py --EnvIdex 1
The --EnvIdex
can be set to be 0~5, where
'--EnvIdex 0' for 'Pendulum-v1'
'--EnvIdex 1' for 'LunarLanderContinuous-v2'
'--EnvIdex 2' for 'Humanoid-v4'
'--EnvIdex 3' for 'HalfCheetah-v4'
'--EnvIdex 4' for 'BipedalWalker-v3'
'--EnvIdex 5' for 'BipedalWalkerHardcore-v3'
Note: if you want train on BipedalWalker, BipedalWalkerHardcore, or LunarLanderContinuous, you need to install box2d-py first. You can install box2d-py via:
pip install gymnasium[box2d]
if you want train on Humanoid or HalfCheetah, you need to install MuJoCo first. You can install MuJoCo via:
pip install mujoco
pip install gymnasium[mujoco]
You can use the tensorboard to record anv visualize the training curve.
pip install tensorboard
pip install packaging
python main.py --write True
tensorboard --logdir runs
For more details of Hyperparameter Setting, please check 'main.py'
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。