Loss Functions¶
Loss functions implemented in PyKEEN and additionally imported from torch
.
Name |
Reference |
---|---|
bce |
|
bceaftersigmoid |
|
crossentropy |
|
marginranking |
|
mse |
|
nssa |
|
softplus |
Note
This table can be re-generated with pykeen ls losses -f rst
-
class
pykeen.losses.
BCEAfterSigmoidLoss
(reduction='mean')[source]¶ A loss function which uses the numerically unstable version of explicit Sigmoid + BCE.
Initializes internal Module state, shared by both nn.Module and ScriptModule.
-
forward
(logits, labels, **kwargs)[source]¶ Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.- Return type
FloatTensor
-
-
class
pykeen.losses.
CrossEntropyLoss
(reduction='mean')[source]¶ Evaluate cross entropy after softmax output.
Initializes internal Module state, shared by both nn.Module and ScriptModule.
-
forward
(logits, labels, **kwargs)[source]¶ Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.- Return type
FloatTensor
-
-
pykeen.losses.
Loss
¶ alias of
torch.nn.modules.loss._Loss
-
class
pykeen.losses.
NSSALoss
(margin, adversarial_temperature, reduction='mean')[source]¶ An implementation of the self-adversarial negative sampling loss function proposed by [sun2019].
Initializes internal Module state, shared by both nn.Module and ScriptModule.