def evaluate_wikikg2(model, loader, mode, save_path):
    from ogb.linkproppred import Evaluator
    evaluator = Evaluator(name='ogbl-wikikg2')
    model.eval()
    with paddle.no_grad():
        y_pred_pos = []
        y_pred_neg = []
        for (h, r, t, neg_h, neg_t) in tqdm(loader):
            pos_h = model._get_ent_embedding(h)
            pos_r = model._get_rel_embedding(r)
            pos_t = model._get_ent_embedding(t)
            y_pred_pos.append(model(pos_h, pos_r, pos_t).numpy())
            y_neg_head = model.predict(t, r, neg_h, mode='head').numpy()
            y_neg_tail = model.predict(h, r, neg_t, mode='tail').numpy()
            y_pred_neg.append(np.concatenate([y_neg_head, y_neg_tail], axis=1))
        y_pred_pos = np.concatenate(y_pred_pos, axis=0)
        y_pred_neg = np.concatenate(y_pred_neg, axis=0)
        input_dict = {'y_pred_pos': y_pred_pos, 'y_pred_neg': y_pred_neg}
        result = evaluator.eval(input_dict)
    logging.info(('-- %s results ------------' % mode))
    logging.info((' ' + ' '.join(['{}: {}'.format(k, v.mean()) for (k, v) in result.items()])))
def evaluate_wikikg2(model, loader, mode, save_path):
    from ogb.linkproppred import Evaluator
    evaluator = Evaluator(name='ogbl-wikikg2')
    model.eval()
    with paddle.no_grad():
        y_pred_pos = []
        y_pred_neg = []
        for (h, r, t, neg_h, neg_t) in tqdm(loader):
            pos_h = model._get_ent_embedding(h)
            pos_r = model._get_rel_embedding(r)
            pos_t = model._get_ent_embedding(t)
            y_pred_pos.append(model(pos_h, pos_r, pos_t).numpy())
            y_neg_head = model.predict(t, r, neg_h, mode='head').numpy()
            y_neg_tail = model.predict(h, r, neg_t, mode='tail').numpy()
            y_pred_neg.append(np.concatenate([y_neg_head, y_neg_tail], axis=1))
        y_pred_pos = np.concatenate(y_pred_pos, axis=0)
        y_pred_neg = np.concatenate(y_pred_neg, axis=0)
        input_dict = {'y_pred_pos': y_pred_pos, 'y_pred_neg': y_pred_neg}
        result = evaluator.eval(input_dict)
    logging.info(('-- %s results ------------' % mode))
    logging.info((' ' + ' '.join(['{}: {}'.format(k, v.mean()) for (k, v) in result.items()])))