Files
kair_algorithms_draft/scripts/run_lunarlander_continuous.py
T
Seungjae Ryan Lee 00c3dc4286 Remove DDPG (#28)
* Change default algorithm from DDPG to SAC

* Remove DDPG examples

* Remove DDPG algorithms

DDPG, DDPG+PER, DDPGfD

* Fix parser bug in LunarLanderContinuous
2019-03-21 23:51:39 +09:00

73 lines
2.0 KiB
Python

# -*- coding: utf-8 -*-
"""Train or test baselines on LunarLanderContinuous-v2.
- Author: Curt Park
- Contact: curt.park@medipixel.io
"""
import argparse
import importlib
import gym
import algorithms.common.helper_functions as common_utils
# configurations
parser = argparse.ArgumentParser(description="Pytorch RL baselines")
parser.add_argument(
"--seed", type=int, default=777, help="random seed for reproducibility"
)
parser.add_argument("--algo", type=str, default="sac", help="choose an algorithm")
parser.add_argument(
"--load-from",
type=str,
default=None,
help="load the saved model and optimizer at the beginning",
)
parser.add_argument("--episode-num", type=int, default=1500, help="total episode num")
parser.add_argument(
"--max-episode-steps", type=int, default=300, help="max episode step"
)
parser.add_argument(
"--off-render", dest="render", action="store_false", help="turn off rendering"
)
parser.add_argument(
"--render-after",
type=int,
default=0,
help="start rendering after the input number of episode",
)
parser.add_argument("--save-period", type=int, default=100, help="save model period")
parser.add_argument("--log", action="store_true", help="turn on logging")
parser.add_argument("--test", action="store_true", help="test mode (no training)")
parser.add_argument(
"--demo-path",
type=str,
default="data/lunarlander_continuous_demo.pkl",
help="demonstration path",
)
parser.set_defaults(render=True)
args = parser.parse_args()
def main():
"""Main."""
# env initialization
env = gym.make("LunarLanderContinuous-v2")
state_dim = env.observation_space.shape[0]
action_dim = env.action_space.shape[0]
# set a random seed
common_utils.set_random_seed(args.seed, env)
# run
module_path = "examples.lunarlander_continuous_v2." + args.algo
example = importlib.import_module(module_path)
example.run(env, args, state_dim, action_dim)
if __name__ == "__main__":
main()