class StructuredEmbedding(*, embedding_dim=50, scoring_fct_norm=1, entity_initializer=<function xavier_uniform_>, entity_constrainer=<function normalize>, entity_constrainer_kwargs=None, relation_initializer=<pykeen.utils.compose object>, **kwargs)[source]

Bases: Generic[pykeen.typing.HeadRepresentation, pykeen.typing.RelationRepresentation, pykeen.typing.TailRepresentation], pykeen.models.nbase._NewAbstractModel

An implementation of the Structured Embedding (SE) published by [bordes2011].

SE applies role- and relation-specific projection matrices \(\textbf{M}_{r}^{h}, \textbf{M}_{r}^{t} \in \mathbb{R}^{d \times d}\) to the head and tail entities’ embeddings before computing their differences. Then, the \(l_p\) norm is applied and the result is negated such that smaller differences are considered better.

\[f(h, r, t) = - \|\textbf{M}_{r}^{h} \textbf{e}_h - \textbf{M}_{r}^{t} \textbf{e}_t\|_p\]

By employing different projections for the embeddings of the head and tail entities, SE explicitly differentiates the role of an entity as either the subject or object.

Initialize SE.

  • embedding_dim (int) – The entity embedding dimension \(d\). Is usually \(d \in [50, 300]\).

  • scoring_fct_norm (int) – The \(l_p\) norm. Usually 1 for SE.

  • entity_initializer (Union[str, Callable[[FloatTensor], FloatTensor], None]) – Entity initializer function. Defaults to pykeen.nn.init.xavier_uniform_()

  • entity_constrainer (Union[str, Callable[[FloatTensor], FloatTensor], None]) – Entity constrainer function. Defaults to torch.nn.functional.normalize()

  • entity_constrainer_kwargs (Optional[Mapping[str, Any]]) – Keyword arguments to be used when calling the entity constrainer

  • relation_initializer (Union[str, Callable[[FloatTensor], FloatTensor], None]) – Relation initializer function. Defaults to pykeen.nn.init.xavier_uniform_norm_()

  • kwargs – Remaining keyword arguments to forward to pykeen.models.EntityEmbeddingModel

Attributes Summary


The default strategy for optimizing the model’s hyper-parameters

Attributes Documentation

hpo_default: ClassVar[Mapping[str, Any]] = {'embedding_dim': {'high': 256, 'low': 16, 'q': 16, 'type': <class 'int'>}, 'scoring_fct_norm': {'high': 2, 'low': 1, 'type': <class 'int'>}}

The default strategy for optimizing the model’s hyper-parameters