コード例 #1
0
ファイル: main_more.py プロジェクト: HERECJ/two_pass
def evaluate(model, train_mat, test_mat, config, logger, device):
    logger.info("Start evaluation")
    model.eval()
    device = torch.device(config.device)
    with torch.no_grad():
        user_num, item_num = train_mat.shape
        # users = torch.from_numpy(np.random.choice(user_num, min(user_num, 5000), False)).to(device)
        users = np.random.choice(user_num, min(5000, user_num), False)
        evals = Eval()
        m = evals.evaluate_item(train_mat[users, :],
                                test_mat[users, :],
                                users,
                                model,
                                device,
                                topk=50)
    return m
コード例 #2
0
 def evaluate(self, train, test):
     m, n = train.shape
     u, v = self.get_uv()
     users = np.random.choice(m, min(m, 50000), False)
     m = Eval.evaluate_item(train[users, :], test[users, :], u[users, :], v, topk=-1)
     return m