-
Notifications
You must be signed in to change notification settings - Fork 2
/
run_recbole.py
73 lines (65 loc) · 2.6 KB
/
run_recbole.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# @Time : 2020/7/20
# @Author : Shanlei Mu
# @Email : slmu@ruc.edu.cn
# UPDATE
# @Time : 2022/7/8, 2020/10/3, 2020/10/1
# @Author : Zhen Tian, Yupeng Hou, Zihan Lin
# @Email : chenyuwuxinn@gmail.com, houyupeng@ruc.edu.cn, zhlin@ruc.edu.cn
import argparse
from ast import arg
from recbole.quick_start import run_recbole, run_recboles
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--model", "-m", type=str, default="BPR", help="name of models")
parser.add_argument("--dataset", "-d", type=str, default="ml-100k", help="name of datasets")
parser.add_argument('--gpu', type=str, default='0', help='gpu id')
parser.add_argument('--lr', '-l', type=float, default=0.001, help='learing rate')
parser.add_argument('--weight_decay', '-w', type=float, default=1e-8, help='weight decay')
parser.add_argument('--tem', '-t', type=float, default=None, help='temperature')
parser.add_argument('--gamma', '-g', type=float, default=None, help='gamma')
parser.add_argument('--suffix', '-s', type=str, default=None, help='suffix logger')
parser.add_argument("--config_files", type=str, default=None, help="config files")
parser.add_argument("--run", '-r', type=str, default=None, help="config files")
parser.add_argument(
"--nproc", type=int, default=1, help="the number of process in this group"
)
parser.add_argument(
"--ip", type=str, default="localhost", help="the ip of master node"
)
parser.add_argument(
"--port", type=str, default="5678", help="the port of master node"
)
parser.add_argument(
"--world_size", type=int, default=-1, help="total number of jobs"
)
parser.add_argument(
"--group_offset",
type=int,
default=0,
help="the global rank offset of this group",
)
args, _ = parser.parse_known_args()
config_file_list = (
args.config_files.strip().split(" ") if args.config_files else None
)
if args.nproc == 1 and args.world_size <= 0:
run_recbole(
args=args, model=args.model, dataset=args.dataset, config_file_list=config_file_list)
else:
if args.world_size == -1:
args.world_size = args.nproc
import torch.multiprocessing as mp
mp.spawn(
run_recboles,
args=(
args.model,
args.dataset,
config_file_list,
args.ip,
args.port,
args.world_size,
args.nproc,
args.group_offset,
),
nprocs=args.nproc,
)