NLLMulticlass¶
- class ampligraph.latent_features.NLLMulticlass(loss_params={}, verbose=False)¶
Multiclass Negative Log-Likelihood loss.
Introduced in [aC15], this loss can be used when both the subject and objects are corrupted (to use it, pass
corrupt_sides=['s,o']in the embedding model parameters).This loss was re-engineered in [KBK17] where only the object was corrupted to get improved performance (to use it in this way pass
corrupt_sides ='o'in the embedding model parameters).\[\mathcal{L(X)} = -\sum_{x_{e_1,e_2,r_k} \in X} log\,p(e_2|e_1,r_k) -\sum_{x_{e_1,e_2,r_k} \in X} log\,p(e_1|r_k, e_2)\]Example
>>> import ampligraph.latent_features.loss_functions as lfs >>> loss = lfs.NLLMulticlass({'reduction': 'mean'}) >>> isinstance(loss, lfs.NLLMulticlass) True
>>> loss = lfs.get('multiclass_nll') >>> isinstance(loss, lfs.NLLMulticlass) 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 loss-specific hyperparams:
”reduction”: (str) - Specifies whether to “sum” or take the “mean” of loss per sample w.r.t. corruption (default: “sum”).