NSSALoss

class NSSALoss(margin=9.0, adversarial_temperature=1.0, reduction='mean')[source]

Bases: pykeen.losses.SetwiseLoss

An implementation of the self-adversarial negative sampling loss function proposed by [sun2019].

Initialize the NSSA loss.

Parameters
  • margin (float) – The loss’s margin (also written as gamma in the reference paper)

  • adversarial_temperature (float) – The negative sampling temperature (also written as alpha in the reference paper)

Note

The default hyperparameters are based the experiments for FB15K-237 in [sun2019].

Attributes Summary

hpo_default

synonyms

Methods Summary

forward(pos_scores, neg_scores)

Calculate the loss for the given scores.

Attributes Documentation

hpo_default: ClassVar[Mapping[str, Any]] = {'adversarial_temperature': {'high': 1.0, 'low': 0.5, 'type': <class 'float'>}, 'margin': {'high': 30, 'low': 3, 'q': 3, 'type': <class 'int'>}}
synonyms: ClassVar[Optional[Set[str]]] = {'Negative Sampling Self-Adversarial Loss', 'Self-Adversarial Negative Sampling Loss'}

Methods Documentation

forward(pos_scores, neg_scores)[source]

Calculate the loss for the given scores.

Return type

FloatTensor