kge
kge copied to clipboard
Error on tensor scoring
I was following the example on the tensor scoring in the readme file
import torch
from kge.model import KgeModel
from kge.util.io import load_checkpoint
checkpoint = load_checkpoint('fb15k-237-rescal.pt')
model = KgeModel.create_from(checkpoint)
s = torch.Tensor([0, 2,]).long() # subject indexes
p = torch.Tensor([0, 1,]).long() # relation indexes
scores = model.score_sp(s, p) # scores of all objects for (s,p,?)
o = torch.argmax(scores, dim=-1) # index of highest-scoring objects
print(o)
print(model.dataset.entity_strings(s)) # convert indexes to mentions
print(model.dataset.relation_strings(p))
print(model.dataset.entity_strings(o))
When running
print(model.dataset.entity_strings(s))
print(model.dataset.entity_strings(o))
It returns the following error
Traceback (most recent call last):
File "
I've downloaded all the data through the bash script. Am I missing something?
Thanks for pointing this out. The pretrained checkpoint used an old naming scheme. For now, it suffices to copy (not rename) entity_ids.del to entity_map.del, likewise relation_ids.del to relations_map.del, in the dataset folder.
I leave this issue open until we fixed this backward compatibility issue.