forked from nikke-rookie/PAMCL
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
36 lines (31 loc) · 977 Bytes
/
main.py
File metadata and controls
36 lines (31 loc) · 977 Bytes
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
from SELFRec import SELFRec
from util.conf import ModelConf
import argparse
import random
import os
import numpy as np
import torch
parser = argparse.ArgumentParser(description="Used to replace the configuration file path.")
parser.add_argument('--config', '-c', type=str, default=None, help='Path to the configuration file.')
args = parser.parse_args()
def seed_it(seed):
random.seed(seed)
os.environ["PYTHONSEED"] = str(seed)
np.random.seed(seed)
torch.cuda.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = True
torch.backends.cudnn.enabled = True
torch.manual_seed(seed)
if __name__ == '__main__':
if args.config is not None:
conf = ModelConf(args.config)
else:
conf = ModelConf(f'./conf/yelp.yaml')
seed_it(conf['seed'])
rec = SELFRec(conf)
if conf['model']['eval'] == True:
rec.execute(is_eval=True)
else:
rec.execute()