besskge.embedding.initialize_relation_embedding

besskge.embedding.initialize_relation_embedding(n_relation_type, inverse_relations, initializer, row_size=None)[source]

Initialize relation embedding table.

Parameters:
  • n_relation_type (int) – Number of relation types.

  • inverse_relations (bool) – If True, learn embeddings for inverse relations, in addition to direct ones. Needs to be set to True when inverse triples are added to the dataset. Given a relation with ID i, its inverse is the one with ID i+n_relation_type.

  • initializer (Union[Tensor, List[Callable[..., Tensor]]]) – Embedding table or list of initializing functions. If providing list of initializers, this needs to be of same length as row_size.

  • row_size (Optional[List[int]]) – Number of parameters for each relation type. This needs to be a list, with the lengths of the different embedding tensors to allocate for each relation. Each embedding tensor, once allocated, is initialized with the corresponding entry of initializer. Can be omitted if passing an embedding table as initializer.

Return type:

Parameter

Returns:

Relation embedding table.