-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathtrain.py
40 lines (29 loc) · 1001 Bytes
/
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
# coding=utf-8
import os
import torch
import numpy as np
import logging
import argparse
from gnn_hpool.utils import hparam
def main(args):
hparams = hparam.HParams()
hparams.from_yaml(args.hparam_path)
# reproducibility
if hparams.device == 'cuda':
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = False
torch.manual_seed(1024)
np.random.seed(1024)
# set default GPU
os.environ['CUDA_VISIBLE_DEVICES'] = hparams.cuda_visible_devices
from gnn_hpool.bin import train_eval
train_eval.train_eval(hparams)
if __name__ == '__main__':
logging.getLogger().setLevel(logging.INFO)
parser = argparse.ArgumentParser(description='Parameters for the training of GNN')
parser.add_argument('--hparam_path', nargs='?', type=str,
default='./config/hparams_testdb.yml',
help='The path to .yml file which contains all the hyperparameters.'
)
args = parser.parse_args()
main(args)