-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
60 lines (47 loc) · 1.43 KB
/
main.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
import yaml
from utils import ordered_yaml, load_config
import random
import torch
from trainers import (
GNNTrainer,
CausalGNNTrainer,
CausalSTGNNTrainer,
BaselinesTrainer
)
from pretrainers import (
Pretrainer
)
# Set seed
seed = 612
random.seed(seed)
torch.manual_seed(seed)
#############################################################
# Set modes:
# train: initialize trainer for classification
# pretrain: pretrain the node embeddings
# eval: Evaluate the trained model
#############################################################
mode = "train"
# mode = "pretrain"
def main():
if mode == "train":
config_name = "HGT_Causal_MIMIC3.yml"
config = load_config(config_name)
if config["train_type"] == "gnn":
trainer = GNNTrainer(config)
elif config["train_type"] == "causal-gnn":
trainer = CausalGNNTrainer(config)
elif config["train_type"] == "causal-gnn-st":
trainer = CausalSTGNNTrainer(config)
elif config["train_type"] == "baseline":
trainer = BaselinesTrainer(config)
else:
raise NotImplementedError("This type of model is not implemented")
trainer.train()
elif mode == "pretrain":
config_name = "MIMIC3_TransE.yml"
config = load_config(config_name, "./configs/pretrain/")
pretrainer = Pretrainer(config)
pretrainer.train()
if __name__ == "__main__":
main()