NLLLoss¶
- class ampligraph.latent_features.NLLLoss(loss_params={}, verbose=False)¶
Negative Log-Likelihood loss.
As described in [TWR+16].
\[\mathcal{L}(\Theta) = \sum_{t \in \mathcal{G} \cup \mathcal{C}}log(1 + exp(-y \, f_{model}(t;\Theta)))\]where \(y \in \{-1, 1\}\) is the label of the statement, \(\mathcal{G}\) is the set of positives, \(\mathcal{C}\) is the set of corruptions and \(f_{model}(t;\Theta)\) is the model-specific scoring function.
Example
>>> import ampligraph.latent_features.loss_functions as lfs >>> loss = lfs.NLLLoss({'reduction': 'mean'}) >>> isinstance(loss, lfs.NLLLoss) True
>>> loss = lfs.get('nll') >>> isinstance(loss, lfs.NLLLoss) True
Attributes
external_paramsnameMethods
__init__([loss_params, verbose])Initialize the loss..
- __init__(loss_params={}, verbose=False)¶
Initialize the loss..
- Parameters:
loss_params (dict) –
Dictionary of hyperparams. No hyperparameters are required for this loss except for “reduction”.
”reduction”: (str) - Specifies whether to “sum” or take “mean” of loss per sample w.r.t. corruption (default:”sum”).