nn_hinge_embedding_loss {torch} | R Documentation |
Hinge embedding loss
Description
Measures the loss given an input tensor and a labels tensor
(containing 1 or -1).
Usage
nn_hinge_embedding_loss(margin = 1, reduction = "mean")
Arguments
margin |
(float, optional): Has a default value of |
reduction |
(string, optional): Specifies the reduction to apply to the output:
|
Details
This is usually used for measuring whether two inputs are similar or
dissimilar, e.g. using the L1 pairwise distance as , and is typically
used for learning nonlinear embeddings or semi-supervised learning.
The loss function for
-th sample in the mini-batch is
and the total loss functions is
where .
Shape
Input:
where
means, any number of dimensions. The sum operation operates over all the elements.
Target:
, same shape as the input
Output: scalar. If
reduction
is'none'
, then same shape as the input