-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathtrain_ddpm_iql_offline.py
93 lines (76 loc) · 3.75 KB
/
train_ddpm_iql_offline.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
import os
import numpy as np
from absl import app, flags
from examples.states.train_diffusion_offline import call_main
from launcher.hyperparameters import set_hyperparameters
FLAGS = flags.FLAGS
flags.DEFINE_integer('variant', 0, 'Logging interval.')
def main(_):
constant_parameters = dict(project='offline_schedule_final',
experiment_name='ddpm_iql',
max_steps=3000001, #Actor takes two steps per critic step
batch_size=512,
eval_episodes=50,
log_interval=1000,
eval_interval=250000,
save_video = False,
filter_threshold=None,
take_top=None,
online_max_steps = 0,
unsquash_actions=False,
normalize_returns=True,
training_time_inference_params=dict(
N = 64,
clip_sampler = True,
M = 0,),
rl_config=dict(
model_cls='DDPMIQLLearner',
actor_lr=3e-4,
critic_lr=3e-4,
value_lr=3e-4,
T=5,
N=64,
M=0,
actor_dropout_rate=0.1,
actor_num_blocks=3,
decay_steps=int(3e6),
actor_layer_norm=True,
value_layer_norm=True,
actor_tau=0.001,
beta_schedule='vp',
))
sweep_parameters = dict(
seed=list(range(10)),
env_name=['walker2d-medium-v2', 'walker2d-medium-replay-v2', 'walker2d-medium-expert-v2',
'halfcheetah-medium-v2', 'halfcheetah-medium-replay-v2', 'halfcheetah-medium-expert-v2',
'hopper-medium-v2', 'hopper-medium-replay-v2', 'hopper-medium-expert-v2',
'antmaze-umaze-v2', 'antmaze-umaze-diverse-v2', 'antmaze-medium-diverse-v2',
'antmaze-medium-play-v2', 'antmaze-large-diverse-v2', 'antmaze-large-play-v2',],
)
variants = [constant_parameters]
name_keys = ['experiment_name', 'env_name']
variants = set_hyperparameters(sweep_parameters, variants, name_keys)
inference_sweep_parameters = dict(
N = [16, 64, 256],
clip_sampler = [True],
M = [0],
)
inference_variants = [{}]
name_keys = []
inference_variants = set_hyperparameters(inference_sweep_parameters, inference_variants)
filtered_variants = []
for variant in variants:
variant['rl_config']['T'] = variant['T']
variant['rl_config']['beta_schedule'] = variant['beta_schedule']
variant['inference_variants'] = inference_variants
if 'antmaze' in variant['env_name']:
variant['rl_config']['critic_hyperparam'] = 0.9
else:
variant['rl_config']['critic_hyperparam'] = 0.7
filtered_variants.append(variant)
print(len(filtered_variants))
variant = filtered_variants[FLAGS.variant]
print(FLAGS.variant)
call_main(variant)
if __name__ == '__main__':
app.run(main)