num_negatives = args.num_neg learner = args.learner learning_rate = args.lr batch_size = args.batch_size epochs = args.epochs verbose = args.verbose topK = 1 evaluation_threads = 1 # mp.cpu_count() print("MLP arguments: %s " % (args)) model_out_file = 'Pretrain/savedmodel' # Loading data t1 = time() dataset = Dataset(args.path + args.dataset) train, testRatings, testNegatives = dataset.trainMatrix, dataset.testRatings, dataset.testNegatives num_users, num_items = train.shape print("Load data done [%.1f s]. #user=%d, #item=%d, #train=%d, #test=%d" % (time() - t1, num_users, num_items, train.nnz, len(testRatings))) # Build model model = get_model(num_users, num_items, layers, reg_layers) #model.load_weights('Pretrain/savedmodel') if learner.lower() == "adagrad": model.compile(optimizer=Adagrad(lr=learning_rate), loss='binary_crossentropy') elif learner.lower() == "rmsprop": model.compile(optimizer=RMSprop(lr=learning_rate), loss='binary_crossentropy') elif learner.lower() == "adam": model.compile(optimizer=Adam(lr=learning_rate), loss='binary_crossentropy') else:
layers = eval(args.layers) reg_layers = eval(args.reg_layers) num_negatives = args.num_neg learner = args.learner learning_rate = args.lr batch_size = args.batch_size epochs = args.epochs verbose = args.verbose evaluation_threads = 1 # mp.cpu_count() print("MLP arguments: %s " % (args)) model_out_file = '%s_MLP_%s_%d.h5' % (args.dataset, args.layers, time()) # Loading data t1 = time() dataset = Dataset(dataset) train, testRatings, testNegatives = dataset.trainMatrix, dataset.testRatings, dataset.testNegatives num_users, num_items = train.shape print("Load data done [%.1f s]. #user=%d, #item=%d, #train=%d, #test=%d" % (time() - t1, num_users, num_items, train.nnz, len(testRatings))) # Build model model = get_model(num_users, num_items, layers, reg_layers) if learner.lower() == "adagrad": model.compile(optimizer=Adagrad(lr=learning_rate), loss='binary_crossentropy') elif learner.lower() == "rmsprop": model.compile(optimizer=RMSprop(lr=learning_rate), loss='binary_crossentropy') elif learner.lower() == "adam": model.compile(optimizer=Adam(lr=learning_rate), loss='binary_crossentropy') else: model.compile(optimizer=SGD(lr=learning_rate), loss='binary_crossentropy')