torchkge-team / torchkge

TorchKGE: Knowledge Graph embedding in Python and PyTorch.
Other
382 stars 41 forks source link

get_embeddings() #210

Closed Zibo-Zhao closed 2 years ago

Zibo-Zhao commented 3 years ago

Hi does the idx of returned tensor corresponding to the idx in ent2idx, or the returned embeddings tensor is not ordered.

if returned tensor has size 131414 and ent2idx also has size 131414, does this mean I can access each entity's embedding by using tensor[ent2idx['entity_name']].

Zibo-Zhao commented 3 years ago

Besides, I found even though I provide the same kg, the returned embedding tensor may have different sizes.

armand33 commented 3 years ago

Hi,

The returned tensor as the shape n_entities x embedding_dim and indeed the index of the first dimension matches the indexes in ent2idx.

Embedding tensor might only differ in shape according to the second axis (the embedding dimension) if you provide a different hyper-parameter. If the KG is the same, the number of entities is the same and then the dimension along the first axis is the same (because it is the number of dimensions).

If this is not the case, there surely is a problem somewhere. Please provide a working code example to reproduce.

armand33 commented 2 years ago

Just closed this issue because of the lack of response from @Zibo-Zhao.