PairwiseLoss

class ampligraph.latent_features.PairwiseLoss(eta, loss_params=None, 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[, loss_params, verbose])

Initialize Loss.

__init__(eta, loss_params=None, verbose=False)

Initialize Loss.

Parameters
  • eta (int) – Number of negatives.

  • loss_params (dict) –

    Dictionary of loss-specific hyperparams:

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

    Example: loss_params={'margin': 1}