Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on tensor scoring #273

Open
ramesesz opened this issue May 11, 2023 · 1 comment
Open

Error on tensor scoring #273

ramesesz opened this issue May 11, 2023 · 1 comment

Comments

@ramesesz
Copy link

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 "", line 1, in
File "/home/ramab/workspace/kge/kge/dataset.py", line 494, in entity_strings
map_ = self.load_map(
File "/home/ramab/workspace/kge/kge/dataset.py", line 315, in load_map
ids = self.load_map(ids_key, as_list=True)
File "/home/ramab/workspace/kge/kge/dataset.py", line 296, in load_map
self.ensure_available(key)
File "/home/ramab/workspace/kge/kge/dataset.py", line 88, in ensure_available
raise IOError(
OSError: File /home/ramab/workspace/kge/data/fb15k-237/entity_map.del for key entity_ids could not be found

I've downloaded all the data through the bash script. Am I missing something?

@rgemulla
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants