Created
June 20, 2019 19:50
-
-
Save sbalnojan/994c467a6e514f51a729c6753bc36430 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print("finally, let's do some ranking...") | |
entity_count = 8 | |
scores, _, _ = comparator( | |
comparator.prepare(torch.tensor(src_embedding.reshape([1,1,10]))).expand(1, entity_count, 10), | |
comparator.prepare(torch.tensor(dest_embeddings.reshape([1,8,10]))), | |
torch.empty(1, 0, 10), # Left-hand side negatives, not needed | |
torch.empty(1, 0, 10), # Right-hand side negatives, not needed | |
) | |
permutation = scores.flatten().argsort(descending=True) | |
top_entities = [dictionary["entities"]["user_id"][index] for index in permutation] | |
print(top_entities) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment