-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathonline_control.py
69 lines (60 loc) · 2.04 KB
/
online_control.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
import ray
import torch
from ray import tune
from experiments import EXPERIMENT_DIR
from experiments.trainable import Loop
from pandemonium.implementations.q_learning import create_horde
from pandemonium.utilities.schedules import LinearSchedule
EXPERIMENT_NAME = 'OnlineControl'
total_steps = int(1e5)
if __name__ == "__main__":
ray.init(local_mode=True)
analysis = tune.run(
Loop,
name=EXPERIMENT_NAME,
# num_samples=3, # number of seeds
local_dir=EXPERIMENT_DIR,
verbose=1,
stop={"timesteps_total": total_steps},
config={
# Model a.k.a. Feature Extractor
'feature_name': 'identity',
'feature_cfg': {},
# Policy
'policy_name': 'egreedy',
'policy_cfg': {
'param': LinearSchedule(
schedule_timesteps=total_steps // 2,
final_p=0.001, initial_p=1,
)
},
# Architecture
'gamma': 1.,
'trace_decay': tune.grid_search(torch.arange(0, 1.1, 0.1).tolist()),
# Optimizer a.k.a. Horde
"horde_fn": create_horde,
# === RLLib params ===
"use_pytorch": True,
"env": "MiniGrid-EmptyEnv6x6-Simple-v0",
"rollout_fragment_length": 1,
# --- Evaluation ---
# "evaluation_interval": 1000, # per training iteration
# from experiments.tools.evaluation import eval_fn
# "custom_eval_function": eval_fn,
# "evaluation_num_episodes": 1,
# "evaluation_config": {
# 'eval_env': env_creator,
# 'eval_env_config': {},
# },
#
# # FIXME: hack to get the evaluation through
# "model": {
# 'conv_filters': [
# [8, [2, 2], 1],
# [16, [2, 2], 1],
# [32, [2, 2], 1],
# ],
# 'fcnet_hiddens': [256]
# }
}
)