liuxiyang641 / RAGAT

RAGAT: Relation Aware Graph Attention Network for Knowledge Graph Completion
56 stars 16 forks source link

关于头部实体替换是哪一行代码 #10

Closed linxiang1911 closed 1 year ago

linxiang1911 commented 1 year ago

imageimage 你好,我有个问题,我只想替换掉头部实体进行结果评估,那我应该保留哪一行结果呢

liuxiyang641 commented 1 year ago

你好,请问你的想法是让挖掉头实体,根据尾实体和关系预测头实体吗? 如果是这样的话,head_batch对应的应该是预测头实体。 可以参考下数据处理部分的代码:


for split in ['test', 'valid']:
            for sub, rel, obj in self.data[split]:
                rel_inv = rel + self.p.num_rel
                self.triples['{}_{}'.format(split, 'tail')].append(
                    {'triple': (sub, rel, obj), 'label': self.sr2o_all[(sub, rel)]})
                self.triples['{}_{}'.format(split, 'head')].append(
                    {'triple': (obj, rel_inv, sub), 'label': self.sr2o_all[(obj, rel_inv)]})
linxiang1911 commented 1 year ago

谢谢您的回复!再确认一下,那我只要保留right_result的结果是吗?我是想保留关系和尾部实体,然后预测头部实体的hit@10的命中率。

liuxiyang641 commented 1 year ago

我认为是这样的,但是为了确保不出错,建议调试代码再确认下