forked from likith012/mulEEG
-
Notifications
You must be signed in to change notification settings - Fork 0
/
train.py
executable file
·56 lines (46 loc) · 1.27 KB
/
train.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
import wandb
import numpy as np
import torch
import argparse
from utils.dataloader import data_generator
from trainer import sleep_pretrain
from config import Config
SEED = 123
torch.manual_seed(SEED)
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = False
np.random.seed(SEED)
parser = argparse.ArgumentParser()
parser.add_argument(
"--name", type=str, default="mulEEG", help="Name for the saved weights"
)
parser.add_argument(
"--data_dir", type=str, default="./SLEEP_data", help="Path to the data"
)
parser.add_argument(
"--save_path", type=str, default="./saved_weights", help="Path to save weights"
)
args = parser.parse_args()
name = args.name
ss_wandb = wandb.init(
project="mulEEG Pretrain",
name=name,
notes="",
save_code=True,
entity="sleep-staging",
)
config = Config(ss_wandb)
config.src_path = args.data_dir
config.exp_path = args.save_path
ss_wandb.save("./config.py")
ss_wandb.save("./trainer.py")
ss_wandb.save("./data_preprocessing/*")
ss_wandb.save("./models/*")
print("Loading Data")
dataloader = data_generator(config.src_path, config)
print("Done")
model = sleep_pretrain(config, name, dataloader, ss_wandb)
print("Model Loaded")
ss_wandb.watch([model], log="all", log_freq=500)
model.fit()
ss_wandb.finish()