-
Notifications
You must be signed in to change notification settings - Fork 0
/
presets.py
120 lines (110 loc) · 4.38 KB
/
presets.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# choose if MPI multi-threading (n > 1) or not (n = 1)
DEFAULT_NCPU = 1
# prepare the default environment
TESTED_ENVS = ['LunarLander-v2', 'MountainCarContinuous-v0', 'BipedalWalker-v3']
# define default parameters for each implemented training algorithm
PRESETS = {'vpg':
{'ac_kwargs': dict(hidden_sizes=[64] * 2),
'gamma': 0.99,
'seed': 0,
'steps_per_epoch': 4000,
'epochs': 50,
'pi_lr': 3e-4,
'vf_lr': 1e-3, # unique to vpg (not in ddpg)
'max_ep_len': 1000,
'save_freq': 10,
'logger_kwargs': dict(),
'train_v_iters': 80, # unique to vpg (not in ddpg)
'lam': 0.97}, # unique to vpg (not in ddpg)
'ddpg':
{'ac_kwargs': dict(hidden_sizes=[256] * 2),
'gamma': 0.99,
'seed': 0,
'steps_per_epoch': 4000,
'epochs': 100,
'pi_lr': 1e-3,
'q_lr': 1e-3, # unique to ddpg (not in vpg)
'max_ep_len': 1000,
'save_freq': 1,
'logger_kwargs': dict(),
'replay_size': int(1e6), # unique to ddpg (not in vpg)
'polyak': 0.995, # unique to ddpg (not in vpg)
'batch_size': 100, # unique to ddpg (not in vpg)
'start_steps': 10000, # unique to ddpg (not in vpg)
'update_after': 1000, # unique to ddpg (not in vpg)
'update_every': 50, # unique to ddpg (not in vpg)
'act_noise': 0.1, # unique to ddpg (not in vpg)
'num_test_episodes': 10}, # unique to ddpg (not in vpg)
'sac':
{'ac_kwargs': dict(),
'seed': 0,
'steps_per_epoch': 4000,
'epochs': 100,
'replay_size': 1000000,
'gamma': 0.99,
'polyak': 0.995,
'lr': 0.001,
'alpha': 0.2,
'batch_size': 100,
'start_steps': 10000,
'update_after': 1000,
'update_every': 50,
'num_test_episodes': 10,
'max_ep_len': 1000,
'logger_kwargs': dict(),
'save_freq': 1},
'ppo':
{'ac_kwargs': dict(),
'seed': 0,
'steps_per_epoch': 4000,
'epochs': 50,
'gamma': 0.99,
'clip_ratio': 0.2,
'pi_lr': 0.0003,
'vf_lr': 0.001,
'train_pi_iters': 80,
'train_v_iters': 80,
'lam': 0.97,
'max_ep_len': 1000,
'target_kl': 0.01,
'logger_kwargs': dict(),
'save_freq': 10},
'td3':
{'ac_kwargs': dict(),
'seed': 0,
'steps_per_epoch': 4000,
'epochs': 100,
'replay_size': 1000000,
'gamma': 0.99,
'polyak': 0.995,
'pi_lr': 0.001,
'q_lr': 0.001,
'batch_size': 100,
'start_steps': 10000,
'update_after': 1000,
'update_every': 50,
'act_noise': 0.1,
'target_noise': 0.2,
'noise_clip': 0.5,
'policy_delay': 2,
'num_test_episodes': 10,
'max_ep_len': 1000,
'logger_kwargs': dict(),
'save_freq': 1}
}
IMPLEMENTED_ALGOS = PRESETS.keys()
# provides a default ActorCritic
DEFAULT_ACTOR_CRITIC = {"vpg": "MLPActorCritic",
"ddpg": "MLPActorCritic",
"sac": "MLPActorCritic",
"ppo": "MLPActorCritic",
"td3": "MLPActorCritic"}
# how the experiment directories are written
def outdir_from_preset(algo, use_custom, exp):
if use_custom:
variant = 'HLML'
else:
variant = 'spinningup'
# e.g. 'vpg_HLML_LunarLander-v2' or 'vpg_spinningup_LunarLander-v2'
experiment_name = '%s_%s_%s' % (algo, variant, exp)
return experiment_name