forked from jaywonchung/BERT4Rec-VAE-Pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
44 lines (37 loc) · 1.41 KB
/
main.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
from options import args
from models import model_factory
from dataloaders import dataloader_factory
from trainers import trainer_factory
from utils import *
def train():
export_root = setup_train(args)
train_loader, val_loader, test_loader, _ = dataloader_factory(args)
print('template = %s\t model_code = %s\n' % (args.template, args.model_code))
model = model_factory(args)
trainer = trainer_factory(args, model, train_loader, val_loader, test_loader, export_root)
trainer.train()
trainer.test()
# test_model = (input('Test model with test dataset? y/[n]: ') == 'y')
# if test_model:
def test50():
export_root = setup_train(args)
train_loader, val_loader, test_loader, _ = dataloader_factory(args)
print('template = %s\t model_code = %s\n' % (args.template, args.model_code))
model = model_factory(args)
trainer = trainer_factory(args, model, train_loader, val_loader, test_loader, export_root)
trainer.test_top50(_.top50)
if __name__ == '__main__':
if args.mode == 'train':
dim_list = [500]
if args.trainer_code in ['bert', 'ncf']:
dim_list = [8, 16, 32, 64]
for i in dim_list:
args.bert_hidden_units = i
args.dae_latent_dim = i
args.vae_latent_dim = i
args.dim = i
train()
if args.mode == 'test50':
test50()
else:
raise ValueError('Invalid mode')