-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathgenerate_psr_grid_search_runs.py
More file actions
42 lines (33 loc) · 1.64 KB
/
generate_psr_grid_search_runs.py
File metadata and controls
42 lines (33 loc) · 1.64 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
40
41
42
# -------------------------------------------------------------------------------------------------------------------------------------
# Following code curated for GCPNet (https://github.com/BioinfoMachineLearning/GCPNet):
# -------------------------------------------------------------------------------------------------------------------------------------
import os
import itertools
import json
# define constants #
TASK = "psr" # 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 DDO AFU FG VG"],
"model.model_cfg.num_encoder_layers": [5],
"model.layer_cfg.mp_cfg.num_message_layers": [8],
"model.optimizer.lr": [1e-4],
"model.optimizer.weight_decay": [0],
"model.model_cfg.dropout": [0.1],
"model.model_cfg.dense_dropout": [0.1],
"model.module_cfg.ablate_frame_updates": [True, False],
"model.module_cfg.frame_gate": [True, False],
"model.module_cfg.vector_gate": [True, False]
}
# 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()