KG2E

class KG2E(*, embedding_dim=50, dist_similarity=None, c_min=0.05, c_max=5.0, entity_initializer=<function uniform_>, entity_constrainer=<function clamp_norm>, entity_constrainer_kwargs=None, relation_initializer=<function uniform_>, relation_constrainer=<function clamp_norm>, relation_constrainer_kwargs=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}_i(\mu_i,\Sigma_i)\) where the mean \(\mu_i \in \mathbb{R}^d\) denotes the position in the vector space and the diagonal variance \(\Sigma_i \in \mathbb{R}^{d \times d}\) models the uncertainty. Inspired by the pykeen.models.TransE model, relations are modeled as transformations from head to tail entities: \(\mathcal{H} - \mathcal{T} \approx \mathcal{R}\) where \(\mathcal{H} \sim \mathcal{N}_h(\mu_h,\Sigma_h)\), \(\mathcal{H} \sim \mathcal{N}_t(\mu_t,\Sigma_t)\), \(\mathcal{R} \sim \mathcal{P}_r = \mathcal{N}_r(\mu_r,\Sigma_r)\), and \(\mathcal{H} - \mathcal{T} \sim \mathcal{P}_e = \mathcal{N}_{h-t}(\mu_h - \mu_t,\Sigma_h + \Sigma_t)\) (since head and tail entities are considered to be independent with regards to the relations). The interaction model measures the similarity between \(\mathcal{P}_e\) and \(\mathcal{P}_r\) by means of the Kullback-Liebler Divergence (KG2E.kullback_leibler_similarity()).

\[f(h,r,t) = \mathcal{D_{KL}}(\mathcal{P}_e, \mathcal{P}_r)\]

Besides the asymmetric KL divergence, the authors propose a symmetric variant which uses the expected likelihood (KG2E.expected_likelihood())

\[f(h,r,t) = \mathcal{D_{EL}}(\mathcal{P}_e, \mathcal{P}_r)\]

Initialize KG2E.

Parameters:

Attributes Summary

constrainer_default_kwargs

The default settings for the entity constrainer

hpo_default

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