DistMult
- class DistMult(*, embedding_dim: int = 50, entity_initializer: str | ~typing.Callable[[~torch.Tensor], ~torch.Tensor] | None = <function xavier_uniform_>, entity_constrainer: str | ~typing.Callable[[~torch.Tensor], ~torch.Tensor] | None = <function normalize>, relation_initializer: str | ~typing.Callable[[~torch.Tensor], ~torch.Tensor] | None = <pykeen.utils.compose object>, regularizer: str | ~pykeen.regularizers.Regularizer | type[~pykeen.regularizers.Regularizer] | None = <class 'pykeen.regularizers.LpRegularizer'>, regularizer_kwargs: ~collections.abc.Mapping[str, ~typing.Any] | None = None, entity_representations_kwargs: ~collections.abc.Mapping[str, ~typing.Any] | None = None, relation_representations_kwargs: ~collections.abc.Mapping[str, ~typing.Any] | None = None, **kwargs)[source]
Bases:
ERModel
[Tensor
,Tensor
,Tensor
]An implementation of DistMult from [yang2014].
In this work, both entities and relations are represented by \(d\)-dimensional vectors stored in an
Embedding
matrix. The entity representation vectors are further constrained to have unit \(L_2\) norm. For the relation representations, a (soft) regularization term on the vector \(L_2\) norm is used instead.The representations are then passed to the
DistMultInteraction
function to obtain scores.This DistMult model can be seen as a simplification of the
RESCAL
model, where the relation matrices are restricted to diagonal matrices: Because of its restriction to diagonal matrices,DistMult
is computationally cheaper thanRESCAL
, but at the same time it is less expressive. For example, it is not able to model anti-symmetric relations.See also
OpenKE implementation of DistMult
Initialize DistMult.
- Parameters:
embedding_dim (int) – The entity embedding dimension \(d\). Is usually \(d \in [50, 300]\).
entity_initializer (str | Callable[[Tensor], Tensor] | None) – The method used to initialize the entity embedding. Defaults to Xavier/Glorot uniform, c.f. OpenKE
entity_constrainer (str | Callable[[Tensor], Tensor] | None) – The constrainer for entity embeddings. Defaults to unit L2 norm.
relation_initializer (str | Callable[[Tensor], Tensor] | None) – The method used to initialize the relation embedding. Defaults to using Xavier/Glorot uniform first and then normalizing te unit L2 length.
regularizer (str | Regularizer | type[Regularizer] | None) – The relation representation regularizer.
regularizer_kwargs (Mapping[str, Any] | None) – Additional keyword-based parameters. Defaults to
DistMult.regularizer_default_kwargs
for the default regularizer.entity_representations_kwargs (Mapping[str, Any] | None) – Additional parameters to
entity_representations_kwargs
passed topykeen.models.ERModel
. Note that those take precedence of those which are filled in by this class.relation_representations_kwargs (Mapping[str, Any] | None) – Additional parameters to
relation_representations_kwargs
passed topykeen.models.ERModel
. Note that those take precedence of those which are filled in by this class.kwargs – Remaining keyword arguments to forward to
pykeen.models.ERModel
Note
The parameter pair
(regularizer, regularizer_kwargs)
is used forpykeen.regularizers.regularizer_resolver
An explanation of resolvers and how to use them is given in https://class-resolver.readthedocs.io/en/latest/.
Attributes Summary
The default strategy for optimizing the model's hyper-parameters
The LP settings used by [yang2014] for DistMult
Attributes Documentation