PairwiseLoss

class ampligraph.latent_features.PairwiseLoss(eta, hyperparam_dict={'margin': 1}, verbose=False)

Pairwise, max-margin loss.

Introduced in [BUGD+13].
\[\mathcal{L}(\Theta) = \sum_{t^+ \in \mathcal{G}}\sum_{t^- \in \mathcal{C}}max(0, [\gamma + f_{model}(t^-;\Theta) - f_{model}(t^+;\Theta)])\]

where \(\gamma\) is the margin, \(\mathcal{G}\) is the set of positives, \(\mathcal{C}\) is the set of corruptions, \(f_{model}(t;\Theta)\) is the model-specific scoring function.

Methods

__init__(eta[, hyperparam_dict, verbose]) Initialize Loss.
__init__(eta, hyperparam_dict={'margin': 1}, verbose=False)

Initialize Loss.

Parameters:
  • eta (int) – number of negatives
  • hyperparam_dict (dict) –

    dictionary of hyperparams.

    • margin: float. Margin to be used in pairwise loss computation (default:1)