ComplEx

class ampligraph.latent_features.layers.scoring.ComplEx(*args, **kwargs)

Complex Embeddings (ComplEx) scoring layer.

The ComplEx model [TWR+16] is an extension of the ampligraph.latent_features.DistMult bilinear diagonal model.

ComplEx scoring function is based on the trilinear Hermitian dot product in \(\mathbb{C}\):

\[f_{ComplEx}=Re(\langle \mathbf{r}_p, \mathbf{e}_s, \overline{\mathbf{e}_o} \rangle)\]

Note

Since ComplEx embeddings belong to \(\mathbb{C}\), this model uses twice as many parameters as ampligraph.latent_features.DistMult.

Attributes

class_params

external_params

name

Methods

__init__(k)

Initializes the scoring layer.

get_config()

Returns the config of the layer.

__init__(k)

Initializes the scoring layer.

Parameters:

k (int) – Embedding size.

get_config()

Returns the config of the layer.

A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.

The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).

Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.

Returns:

Python dictionary.