-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathgenerate_ar_grid_search_runs.py
More file actions
39 lines (30 loc) · 1.46 KB
/
generate_ar_grid_search_runs.py
File metadata and controls
39 lines (30 loc) · 1.46 KB
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
# -------------------------------------------------------------------------------------------------------------------------------------
# Following code curated for GCPNet (https://github.com/BioinfoMachineLearning/GCPNet):
# -------------------------------------------------------------------------------------------------------------------------------------
import os
import itertools
import json
# define constants #
TASK = "ar" # TODO: Ensure Is Correct Before Each Grid Search!
SCRIPT_DIR = os.path.join("scripts")
SEARCH_SPACE_FILEPATH = os.path.join(SCRIPT_DIR, f"{TASK}_grid_search_runs.json")
def main():
# TODO: Ensure Is Correct Before Each Grid Search!
search_space_dict = {
"gcp_version": [2],
"key_names": ["NEL NML LR WD DO CHD"],
"model.model_cfg.num_encoder_layers": [4],
"model.layer_cfg.mp_cfg.num_message_layers": [4],
"model.optimizer.lr": [1e-3],
"model.optimizer.weight_decay": [1e-3],
"model.model_cfg.dropout": [0.0],
"model.model_cfg.chi_hidden_dim": [32]
}
# gather all combinations of hyperparameters while retaining field names for each chosen hyperparameter
keys, values = zip(*search_space_dict.items())
hyperparameter_dicts = [dict(zip(keys, v)) for v in itertools.product(*values)]
# save search space to storage as JSON file
with open(SEARCH_SPACE_FILEPATH, "w") as f:
f.write(json.dumps(hyperparameter_dicts))
if __name__ == "__main__":
main()