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

Support evaluation directly on a checkpoint #85

Open
rgemulla opened this issue Mar 24, 2020 · 3 comments
Open

Support evaluation directly on a checkpoint #85

rgemulla opened this issue Mar 24, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@rgemulla
Copy link
Member

Right now, only possible with folder structure as used in training.

@rgemulla rgemulla added the enhancement New feature or request label Mar 24, 2020
@DbCrWk
Copy link

DbCrWk commented Apr 17, 2020

This would be really helpful!

@DbCrWk
Copy link

DbCrWk commented Apr 17, 2020

I've written some really back-of-the-envelope code to emulate this behavior

dataset_name = 'fb15k-237'
model_name = 'rescal'
dataset_and_model = dataset_name + '-' + model_name

model = kge.model.KgeModel.load_from_checkpoint(
    ./local/best/' + model_name + '/' + dataset_and_model + '.pt')

s = model.dataset.split('valid').select(1, 0)
p = model.dataset.split('valid').select(1, 1)
o = model.dataset.split('valid').select(1, 2)

scores = model.score_sp(s, p)
raw_ranks = [torch.sum(score_array > score_array[o[i]], dtype=torch.long) for (i, score_array) in enumerate(scores)]
num_ties = [torch.sum(score_array == score_array[o[i]], dtype=torch.long) for (i, score_array) in enumerate(scores)]
final_ranks = [(raw_rank + (num_ties[j] // 2)) for (j, raw_rank) in enumerate(raw_ranks)]

@rgemulla
Copy link
Member Author

Update: first part of this implemented as part of #94. CLI still needs to be updated.

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

No branches or pull requests

2 participants