BoxE
- class BoxE(*, embedding_dim: int = 256, tanh_map: bool = True, p: int = 2, power_norm: bool = False, entity_initializer: str | ~typing.Callable[[~torch.Tensor], ~torch.Tensor] | None = <pykeen.utils.compose object>, entity_initializer_kwargs: ~collections.abc.Mapping[str, ~typing.Any] | None = None, relation_initializer: str | ~typing.Callable[[~torch.Tensor], ~torch.Tensor] | None = <pykeen.utils.compose object>, relation_initializer_kwargs: ~collections.abc.Mapping[str, ~typing.Any] | None = None, relation_size_initializer: str | ~typing.Callable[[~torch.Tensor], ~torch.Tensor] | None = <function uniform_>, relation_size_initializer_kwargs: ~collections.abc.Mapping[str, ~typing.Any] | None = None, **kwargs)[source]
Bases:
ERModel
[tuple
[Tensor
,Tensor
],tuple
[Tensor
,Tensor
,Tensor
,Tensor
,Tensor
,Tensor
],tuple
[Tensor
,Tensor
]]An implementation of BoxE from [abboud2020].
It combines a number of
Embedding
for both entities and relation representations with theBoxEInteraction
function.Note
This implementation only currently supports unimodal knowledge graphs consisting only of binary facts, whereas the original BoxE applies to arbitrary facts of any arity, i.e., unary facts, binary facts, ternary facts, etc. For use on higher-arity knowledge bases, please refer to the original implementation at https://www.github.com/ralphabb/BoxE.
Initialize BoxE.
- Parameters:
embedding_dim (int) – The entity embedding dimension \(d\). Defaults to 200. Is usually \(d \in [50, 300]\).
tanh_map (bool) – Whether to use tanh mapping after BoxE computation (defaults to true). The hyperbolic tangent mapping restricts the embedding space to the range [-1, 1], and thus this map implicitly regularizes the space to prevent loss reduction by growing boxes arbitrarily large.
p (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.uniform_norm_()
entity_initializer_kwargs (Mapping[str, Any] | None) – Keyword arguments to be used when calling the entity initializer
relation_initializer (str | Callable[[Tensor], Tensor] | None) – Relation initializer function. Defaults to
pykeen.nn.init.uniform_norm_()
relation_initializer_kwargs (Mapping[str, Any] | None) – Keyword arguments to be used when calling the relation initializer
relation_size_initializer (str | Callable[[Tensor], Tensor] | None) – Relation initializer function. Defaults to
torch.nn.init.uniform_()
Defaults totorch.nn.init.uniform_()
relation_size_initializer_kwargs (Mapping[str, Any] | None) – Keyword arguments to be used when calling the relation matrix initializer
kwargs – Remaining keyword arguments passed through to
ERModel
.
Attributes Summary
The default strategy for optimizing the model's hyper-parameters
The default parameters for the default loss function class
Attributes Documentation