RGCNRepresentations

class RGCNRepresentations(triples_factory, embedding_specification, num_layers=2, use_bias=True, activation=None, activation_kwargs=None, edge_dropout=0.4, self_loop_dropout=0.2, edge_weighting=None, decomposition=None, decomposition_kwargs=None, regularizer=None, regularizer_kwargs=None)[source]

Bases: pykeen.nn.emb.RepresentationModule

Entity representations enriched by R-GCN.

The GCN employed by the entity encoder is adapted to include typed edges. The forward pass of the GCN is defined by:

\[\textbf{e}_{i}^{l+1} = \sigma \left( \sum_{r \in \mathcal{R}}\sum_{j\in \mathcal{N}_{i}^{r}} \frac{1}{c_{i,r}} \textbf{W}_{r}^{l} \textbf{e}_{j}^{l} + \textbf{W}_{0}^{l} \textbf{e}_{i}^{l}\right)\]

where \(\mathcal{N}_{i}^{r}\) is the set of neighbors of node \(i\) that are connected to \(i\) by relation \(r\), \(c_{i,r}\) is a fixed normalization constant (but it can also be introduced as an additional parameter), and \(\textbf{W}_{r}^{l} \in \mathbb{R}^{d^{(l)} \times d^{(l)}}\) and \(\textbf{W}_{0}^{l} \in \mathbb{R}^{d^{(l)} \times d^{(l)}}\) are weight matrices of the l-th layer of the R-GCN.

The encoder aggregates for each node \(e_i\) the latent representations of its neighbors and its own latent representation \(e_{i}^{l}\) into a new latent representation \(e_{i}^{l+1}\). In contrast to standard GCN, R-GCN defines relation specific transformations \(\textbf{W}_{r}^{l}\) which depend on the type and direction of an edge.

Since having one matrix for each relation introduces a large number of additional parameters, the authors instead propose to use a decomposition, cf. pykeen.nn.message_passing.Decomposition.

Instantiate the R-GCN encoder.

Parameters

Methods Summary

forward([indices])

Enrich the entity embeddings of the decoder using R-GCN message propagation.

post_parameter_update()

Apply constraints which should not be included in gradients.

reset_parameters()

Reset the module's parameters.

Methods Documentation

forward(indices=None)[source]

Enrich the entity embeddings of the decoder using R-GCN message propagation.

Return type

FloatTensor

post_parameter_update()[source]

Apply constraints which should not be included in gradients.

Return type

None

reset_parameters()[source]

Reset the module’s parameters.