num_epochs, batch_size, lr,\ regs_ui, regs_bias, num_factors = \ args.epochs, args.batch_size, args.lr,\ args.regs_ui, args.regs_bias,args.nfactors regs_ui = list(np.float32(eval(regs_ui))) regs_bias = list(np.float32(eval(regs_bias))) # original_matrix = mtl.load_original_matrix('Data/ml-1m/ratings.dat', header=['uid', 'iid', 'ratings', 'time'], sep='::') # train_matrix, test_matrix = mtl.matrix_split(original_matrix, opt='prediction', mode='user', test_size=0.1, seed=42) # gtl.matrix_to_mat('SVD_ML1M_90.mat',opt='coo', original=original_matrix, train=train_matrix, test=test_matrix) # gtl.matrix_to_excel('svd_all.xlsx',opt='coo',train_all=train_matrix, test_all=test_matrix) # print("Saved!") data = gtl.load_mat_as_matrix('Data/SVD_ML1M_90.mat', opt='coo') original_matrix, train_matrix, test_matrix = data['original'], data[ 'train'], data['test'] gpu_options = tf.GPUOptions(allow_growth=True) with tf.Session(config=tf.ConfigProto(allow_soft_placement=True, intra_op_parallelism_threads=8, inter_op_parallelism_threads=8, gpu_options=gpu_options)) as sess: model = SVD(sess, num_factors=num_factors, regs_ui=regs_ui, regs_bias=regs_bias, lr=lr, epochs=num_epochs,
'flixster-5': 'Data/flixster-hr-5.mat', 'ymov-full': 'Data/ymov-hr-full.mat', 'ymov-345': 'Data/ymov-hr-345.mat', 'ymov-45': 'Data/ymov-hr-45.mat', 'ymov-5': 'Data/ymov-hr-5.mat', 'ymus-full': 'Data/ymus-hr-full.mat', 'ymus-345': 'Data/ymus-hr-345.mat', 'ymus-45': 'Data/ymus-hr-45.mat', 'ymus-5': 'Data/ymus-hr-5.mat', } dataset = 'filmtrust-34' path = path_dict[dataset] print('Loading Data From {0}'.format(path)) data = gtl.load_mat_as_matrix(path, opt='coo') original_matrix, train_matrix, test_matrix = data['original'], data['train'], data['test'] print('Users:{0}, Items:{1}, Ratings:{2}'.format(original_matrix.shape[0], original_matrix.shape[1], original_matrix.nnz)) gpu_options = tf.GPUOptions(allow_growth=True) with tf.Session(config=tf.ConfigProto(allow_soft_placement=True, intra_op_parallelism_threads=24, inter_op_parallelism_threads=24, gpu_options=gpu_options)) as sess: model = AMF(sess, top_K=[5,10], num_factors=40, reg=0.015, reg_adv=100, noise_type='grad',
args.topk, args.ranking_ratio, args.nfactors, args.out_neg_ratio, args.epsilon,\ args.ae_regs ae_regs = list(np.float32(eval(ae_regs))) # original_matrix \ # = mtl.load_original_matrix(datafile='Data/ml-1m/ratings.dat', header=['uid', 'iid', 'ratings', 'time'], sep='::') # train_matrix, test_matrix = mtl.matrix_split(original_matrix, opt='prediction', mode='user', test_size=0.1, seed=10) # original_matrix = mtl.matrix_to_binary(original_matrix, 0) # train_matrix, test_matrix = mtl.matrix_to_binary(train_matrix,0), mtl.matrix_to_binary(test_matrix,0) # gtl.matrix_to_mat('Data/ML1M_90_Data.mat', opt='coo', original=original_matrix, train=train_matrix, test=test_matrix) # data = gtl.load_mat_as_matrix('Data/ML1M_90_Data.mat', opt='coo') original_matrix, train_matrix, test_matrix = data['original'], data['train'], data['test'] gpu_options = tf.GPUOptions(allow_growth=True) with tf.Session(config=tf.ConfigProto(allow_soft_placement=True, intra_op_parallelism_threads=8, inter_op_parallelism_threads=8, gpu_options=gpu_options)) as sess: model = GAN_AE(sess, top_K=topK, ranking_list_ratio=ranking_list_ratio, neg_ratio=neg_ratio, num_factors=num_factors, ae_regs=ae_regs, eps=epsilon, lr=lr, epochs=num_epochs, batch_size=batch_size, T=1000, verbose=True) model.prepare_data(original_matrix=original_matrix, train_matrix=train_matrix, test_matrix=test_matrix) model.build_model()
# original_matrix \ # = mtl.load_original_matrix(datafile='Data/ml-1m/ratings.dat', header=['uid', 'iid', 'ratings', 'time'], sep='::') # train_matrix, test_matrix \ # = mtl.matrix_split(original_matrix, opt='prediction', mode='user', test_size=0.2, random_state=10) # train_matrix, test_matrix \ # = mtl.matrix_split(original_matrix, opt='ranking', mode='mat', n_item_per_user=1, random_state=10) # original_matrix = mtl.matrix_to_binary(original_matrix, 0) # train_matrix = mtl.matrix_to_binary(train_matrix, 0) # test_matrix = mtl.matrix_to_binary(test_matrix, 0) # gtl.matrix_to_mat('Data/ML1M_Rank_200_1_Data.mat', opt='coo', original=original_matrix, train=train_matrix, test=test_matrix) data = gtl.load_mat_as_matrix('Data/ML1M_Rank_200_1_Data.mat', opt='coo') original_matrix, train_matrix, test_matrix = data['original'], data[ 'train'], data['test'] gpu_options = tf.GPUOptions(allow_growth=True) with tf.Session(config=tf.ConfigProto(allow_soft_placement=True, intra_op_parallelism_threads=8, inter_op_parallelism_threads=8, gpu_options=gpu_options)) as sess: model = GAN_AE(sess, top_K=topK, neg_ratio=neg_ratio, num_factors=num_factors, ae_regs=ae_regs, eps=40, lr=lr,