KG2E
- class KG2E(*, embedding_dim: int = 50, dist_similarity: str | ~pykeen.nn.sim.KG2ESimilarity | type[~pykeen.nn.sim.KG2ESimilarity] | None = None, dist_similarity_kwargs: ~collections.abc.Mapping[str, ~typing.Any] | None = None, c_min: float = 0.05, c_max: float = 5.0, entity_initializer: str | ~typing.Callable[[~torch.Tensor], ~torch.Tensor] | None = <function uniform_>, entity_constrainer: str | ~typing.Callable[[~torch.Tensor], ~torch.Tensor] | None = <function clamp_norm>, entity_constrainer_kwargs: ~collections.abc.Mapping[str, ~typing.Any] | None = None, relation_initializer: str | ~typing.Callable[[~torch.Tensor], ~torch.Tensor] | None = <function uniform_>, relation_constrainer: str | ~typing.Callable[[~torch.Tensor], ~torch.Tensor] | None = <function clamp_norm>, relation_constrainer_kwargs: ~collections.abc.Mapping[str, ~typing.Any] | None = None, **kwargs)[source]
Bases:
ERModel
An implementation of KG2E from [he2015].
KG2E aims to explicitly model (un)certainties in entities and relations (e.g. influenced by the number of triples observed for these entities and relations). Therefore, entities and relations are represented by probability distributions, in particular by multi-variate Gaussian distributions \(\mathcal{N}(\mu, \Sigma)\) where the mean \(\mu \in \mathbb{R}^d\) denotes the position in the vector space and the diagonal variance \(\Sigma = diag(\sigma_1, \ldots, \sigma_d) \in \mathbb{R}^{d \times d}\) models the uncertainty.
Thus, we have two \(d\)-dimensional vectors each stored in an
Embedding
matrix for entities and also relations. The representations are then passed to theKG2EInteraction
function to obtain scores.Initialize KG2E.
- Parameters:
embedding_dim (int) – The entity embedding dimension \(d\). Is usually \(d \in [50, 350]\).
dist_similarity (str | KG2ESimilarity | type[KG2ESimilarity] | None) – The similarity measures for gaussian distributions. Defaults to
NegativeKullbackLeiblerDivergence
.dist_similarity_kwargs (Mapping[str, Any] | None) – Additional keyword-based parameters used to instantiate the similarity.
c_min (float) – covariance clamp minimum bound
c_max (float) – covariance clamp maximum bound
entity_initializer (str | Callable[[Tensor], Tensor] | None) – Entity initializer function. Defaults to
torch.nn.init.uniform_()
entity_constrainer (str | Callable[[Tensor], Tensor] | None) – Entity constrainer function. Defaults to
pykeen.utils.clamp_norm()
entity_constrainer_kwargs (Mapping[str, Any] | None) – Keyword arguments to be used when calling the entity constrainer
relation_initializer (str | Callable[[Tensor], Tensor] | None) – Relation initializer function. Defaults to
torch.nn.init.uniform_()
relation_constrainer (str | Callable[[Tensor], Tensor] | None) – Relation constrainer function. Defaults to
pykeen.utils.clamp_norm()
relation_constrainer_kwargs (Mapping[str, Any] | None) – Keyword arguments to be used when calling the relation constrainer
kwargs – Remaining keyword arguments to forward to
pykeen.models.ERModel
Note
The parameter pair
(dist_similarity, dist_similarity_kwargs)
is used forpykeen.nn.sim.kg2e_similarity_resolver
An explanation of resolvers and how to use them is given in https://class-resolver.readthedocs.io/en/latest/.
Attributes Summary
The default settings for the entity constrainer
The default strategy for optimizing the model's hyper-parameters
Attributes Documentation
- constrainer_default_kwargs = {'dim': -1, 'maxnorm': 1.0, 'p': 2}
The default settings for the entity constrainer
- hpo_default: ClassVar[Mapping[str, Any]] = {'c_max': {'high': 10.0, 'low': 1.0, 'type': <class 'float'>}, 'c_min': {'high': 0.1, 'low': 0.01, 'scale': 'log', 'type': <class 'float'>}, 'embedding_dim': {'high': 256, 'low': 16, 'q': 16, 'type': <class 'int'>}}
The default strategy for optimizing the model’s hyper-parameters