TransE
- class TransE(*, embedding_dim: int = 50, scoring_fct_norm: int = 1, power_norm: bool = False, 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>, relation_constrainer: str | ~typing.Callable[[~torch.Tensor], ~torch.Tensor] | None = None, regularizer: str | ~pykeen.regularizers.Regularizer | type[~pykeen.regularizers.Regularizer] | None = None, regularizer_kwargs: ~collections.abc.Mapping[str, ~typing.Any] | None = None, **kwargs)[source]
Bases:
ERModel
[Tensor
,Tensor
,Tensor
]An implementation of TransE [bordes2013].
This model represents both entities and relations as \(d\)-dimensional vectors stored in an
Embedding
matrix. The representations are then passed to theTransEInteraction
function to obtain scores.Initialize TransE.
- Parameters:
embedding_dim (int) – The entity embedding dimension \(d\). Is usually \(d \in [50, 300]\).
scoring_fct_norm (int) – The norm used with
torch.linalg.vector_norm()
. Typically is 1 or 2.power_norm (bool) – Whether to use the p-th power of the \(L_p\) norm. It has the advantage of being differentiable around 0, and numerically more stable.
entity_initializer (str | Callable[[Tensor], Tensor] | None) – Entity initializer function. Defaults to
pykeen.nn.init.xavier_uniform_()
.entity_constrainer (str | Callable[[Tensor], Tensor] | None) – Entity constrainer function. Defaults to
torch.nn.functional.normalize()
.relation_initializer (str | Callable[[Tensor], Tensor] | None) – Relation initializer function. Defaults to
pykeen.nn.init.xavier_uniform_norm_()
.relation_constrainer (str | Callable[[Tensor], Tensor] | None) – Relation constrainer function. Defaults to none.
regularizer (str | Regularizer | type[Regularizer] | None) – a regularizer, or a hint thereof. Used for both, entity and relation representations; directly use
ERModel
if you need more flexibilityregularizer_kwargs (Mapping[str, Any] | None) – keyword-based parameters for the regularizer
kwargs – Remaining keyword arguments to forward to
__init__()
See also
OpenKE implementation of TransE
NormBasedInteraction
for a description of the parametersscoring_fct_norm
andpower_norm
.
Attributes Summary
The default strategy for optimizing the model's hyper-parameters
Attributes Documentation