sep="\t") config = tf.ConfigProto() config.gpu_options.allow_growth = True with tf.Session(config=config) as sess: model = None # Model selection if args.model == "CDAE": train_data, test_data, n_user, n_item = load_data_all( test_size=0.2, sep="\t") model = ICDAE(sess, n_user, n_item) if args.model == "CML": model = CML(sess, n_user, n_item) if args.model == "LRML": model = LRML(sess, n_user, n_item) if args.model == "BPRMF": model = BPRMF(sess, n_user, n_item) if args.model == "NeuMF": model = NeuMF(sess, n_user, n_item) if args.model == "GMF": model = GMF(sess, n_user, n_item) if args.model == "MLP": model = MLP(sess, n_user, n_item) if args.model == "JRL": model = JRL(sess, n_user, n_item) # build and execute the model if model is not None: model.build_network() model.execute(train_data, test_data)
kwargs = {'epoch': args.num_epochs, 'T': args.display_step, 'learning_rate': args.learning_rate, 'reg_rate': args.reg_rate, 'male_weight': args.male_weight, 'log_file': log_file} if args.model == 'BPRMF': model = BPRMF(sess, num_users, num_items, **kwargs) if args.model == 'CDAE': model = ICDAE(sess, num_users, num_items, **kwargs) if args.model == 'CML': model = CML(sess, num_users, num_items, **kwargs) if args.model == 'GMF': model = GMF(sess, num_users, num_items, **kwargs) if args.model == 'JRL': model = JRL(sess, num_users, num_items, **kwargs) if args.model == 'LRML': model = LRML(sess, num_users, num_items, **kwargs) if args.model == 'MLP': model = MLP(sess, num_users, num_items, **kwargs) if args.model == 'NeuMF': model = NeuMF(sess, num_users, num_items, **kwargs) if model is None: exit() model.build_network(num_factor=args.num_factors) model.execute(train_data, test_data, user_attr) # print('Final: %04d; ' % (args.num_epochs), end='') # model.test() # save result with open(rec_file, 'w') as fout: for u in model.test_users:
gpus = tf.config.experimental.list_physical_devices('GPU') tf.config.experimental.set_memory_growth(gpus[0], True) except: # Invalid device or cannot modify virtual devices once initialized. pass model = None # Model selection if args.model == "CDAE": train_data, test_data, n_user, n_item = load_data_all(test_size=0.2, sep="\t") # model = ICDAE(n_user, n_item) model = CDAE(n_user, n_item) if args.model == "CML": model = CML(n_user, n_item) if args.model == "LRML": model = LRML(n_user, n_item) if args.model == "BPRMF": model = BPRMF(n_user, n_item) if args.model == "NeuMF": model = NeuMF(n_user, n_item) if args.model == "GMF": model = GMF(n_user, n_item) if args.model == "MLP": model = MLP(n_user, n_item) if args.model == "JRL": model = JRL(n_user, n_item) # build and execute the model if model is not None: model.build_network() model.execute(train_data, test_data)