scikit-kge icon indicating copy to clipboard operation
scikit-kge copied to clipboard

Accessing of embeddings after training

Open MBrighty opened this issue 6 years ago • 3 comments

How do you access the embedding vectors after the training of the model? The documentation is unclear on this matter.

MBrighty avatar Apr 12 '18 11:04 MBrighty

I have the same issue. Were you able to figure it out?

aayushee avatar Nov 26 '18 13:11 aayushee

I'm sorry, I didn't manage to figure it out and decided not to use this package.

MBrighty avatar Nov 27 '18 20:11 MBrighty

For anyone who comes across this, you can access the embeddings as follows (based on the example from the readme). They're parameter objects belonging to the model.

# embeddings for entities; can use like numpy matrix
entity_embeds = trainer.model.E
print(entity_embeds[some_entity_id])

# embeddings for relations
relation_embeds = trainer.model.R
print(relation_embeds[some_relation_id])

jacobdanovitch avatar Apr 19 '19 23:04 jacobdanovitch