-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_benchmarks.py
119 lines (107 loc) · 3.5 KB
/
run_benchmarks.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
from datetime import datetime
from itertools import product as it_product
from gene.experiment import Experiment
from gene.core.distances import get_df
from gene.utils import fail_if_not_device, validate_json
import wandb
CONTINUOUS_CONTROL = "Continuous Control benchmarks"
META_DF = "Meta df benchmarks"
if __name__ == "__main__":
fail_if_not_device()
seeds = list(range(5))
brax_envs = {
"humanoid": {
"observation_space": 240,
"action_space": 8,
},
"walker2d": {
"observation_space": 17,
"action_space": 6,
},
"hopper": {
"observation_space": 11,
"action_space": 3,
},
"ant": {
"observation_space": 87,
"action_space": 8,
},
"halfcheetah": {
"observation_space": 18,
"action_space": 6,
},
}
policy_architecture = ("relu_tanh_linear", "tanh_linear")
policy_layer_dimensions = (
[128, 128],
[32, 32, 32, 32],
)
encoding_types = ("direct", "gene")
experiment_settings = list(
it_product(
seeds,
brax_envs,
policy_architecture,
policy_layer_dimensions,
encoding_types,
)
)
n_total_experiments = len(experiment_settings)
n_total_experiments_emp = (
len(brax_envs.keys())
* len(seeds)
* len(policy_layer_dimensions)
* len(policy_architecture)
* len(encoding_types)
)
assert n_total_experiments == n_total_experiments_emp
config = {
"seed": 0,
"evo": {
"strategy_name": "Sep_CMA_ES",
"n_generations": 500,
"population_size": 256,
"n_evaluations": 1,
},
"net": {"layer_dimensions": []},
"encoding": {"d": 3, "distance": "pL2", "type": "gene"},
"task": {"environnment": "", "maximize": True, "episode_length": 1000},
"distance_network": {"layer_dimensions": None},
}
print(f"[Log - CCBench] - Running {n_total_experiments} experiments")
start_time = datetime.now().strftime("%Y.%m.%d_%H:%M")
for i, (seed, env, arch, dimensions, encoding_type) in enumerate(
experiment_settings
):
config["seed"] = seed
config["task"]["environnment"] = env
config["net"]["architecture"] = arch
config["net"]["layer_dimensions"] = (
[brax_envs[env]["observation_space"]]
+ dimensions
+ [brax_envs[env]["action_space"]]
)
config["encoding"]["type"] = encoding_type
print(
f"[Log - CCBench][{i}] {seed=} |"
+ f" {env=} | {arch=} | {dimensions=} |"
+ f" {config['net']['layer_dimensions']=} | {encoding_type=}"
)
# =============================================================
# NOTE - Start experiment
validate_json(config)
wandb_run = wandb.init(
project=CONTINUOUS_CONTROL,
name=f"{i}-{config['encoding']['type']}-{config['task']['environnment']}",
config=config,
tags=[f"{start_time}"],
)
exp = Experiment(
config=config, wandb_run=wandb_run, distance_function=get_df(config)()
)
# do not save intermediate individuals, only start and end (save_step)
exp.run(
seed=seed,
save_step=2000,
)
print(f"[Log - CCBench] - Finished running {n_total_experiments} experiments")