-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrunner.py
40 lines (34 loc) · 1.05 KB
/
runner.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
import pandas as pd
import numpy as np
import torch
from models.gnn import GNN
from models.mlp import MLP
from utils.dataloader import GetDataloader
from utils.args import get_params
from trainer import Trainer
from tqdm import trange
from tqdm import tqdm
import torch.nn.functional as F
import os
import os.path as osp
import yaml
import random
from datetime import date
import warnings
warnings.filterwarnings("ignore")
if __name__ == '__main__':
# Using config.yaml to get params
with open("config.yaml", "r") as f:
params = yaml.safe_load(f)
params["device"] = 'cpu' if params["device"] == 123 else f"cuda:{params['device']}"
params["exp_name"] = f"{params['exp_name']}_{params['dataset']}_{params['sentence_encoder']}_{date.today()}"
# control random seed
if params['seed'] is not None:
SEED = params['seed']
torch.manual_seed(SEED)
torch.cuda.manual_seed(SEED)
torch.backends.cudnn.deterministic = True
np.random.seed(SEED)
random.seed(SEED)
trnr = Trainer(params)
trnr.train()