xyjigsaw / CENET

Temporal Knowledge Graph Reasoning with Historical Contrastive Learning
MIT License
69 stars 11 forks source link

Can you explain how you obtain filtered version and its reason? I don't understand the following code. #5

Closed Joyce-Jang closed 1 year ago

Joyce-Jang commented 1 year ago
        o_label = cur_o
        ground = preds[i, cur_o].clone().item()
        if self.args.filtering:
            if pred_known == 's':
                s_id = torch.nonzero(all_triples[:, 0] == cur_s).view(-1)
                idx = torch.nonzero(all_triples[s_id, 1] == cur_r).view(-1)
                idx = s_id[idx]
                idx = all_triples[idx, 2]
            else:
                s_id = torch.nonzero(all_triples[:, 2] == cur_s).view(-1)
                idx = torch.nonzero(all_triples[s_id, 1] == cur_r).view(-1)
                idx = s_id[idx]
                idx = all_triples[idx, 0]

            preds[i, idx] = 0
            preds[i, o_label] = ground
xyjigsaw commented 1 year ago

Thanks for your interest in our work. We follow the filtered version from RENET. Thanks again for your careful check 🤗. If there are still some problems, please inform us as soon as possible. Your suggestions can be of help to improve our latest version of CENET.

HuangRiKui commented 1 year ago

According to [1], the evaluation of TKGF includes three settings, raw, static filtering and time-aware filtering. As I understand CENET and RE-NET use static filter settings. Do I understand correctly? If I am correct, is there a time aware filtering of the results?

[1] On the Evaluation of Methods for Temporal Knowledge Graph Forecasting.