Accenture / AmpliGraph

Python library for Representation Learning on Knowledge Graphs https://docs.ampligraph.org
Apache License 2.0
2.14k stars 251 forks source link

Bug in get_embeddings function ConvKB #168

Closed NicholasMcCarthy closed 4 years ago

NicholasMcCarthy commented 4 years ago

Description

Described in #167, ConvKB loads trained model params from a dict with keys: ['ent_emb', 'rel_emb'] instead of a list (indexed: [0, 1]).

There's no reason not to use a dictionary to save trained model parameters - the overhead is negligible and code is easier to read rather than interpreting what different indices of a list are supposed to map to for each model (I realize for most of the models it's just 0 -> entities, 1->relations, but this will get more complicated).

Fix

Change EmbeddingModel:get_embeddings():

if isinstance(self.trained_model_params, list):
   emb_list = self.trained_model_params[0]
else:
   emb_list = self.trained_model_params['ent_emb']

'
'
if isinstance(self.trained_model_params, list):
   rel_list = self.trained_model_params[1]
else:
   rel_list = self.trained_model_params['rel_emb']