nn_cosine_embedding_loss | R Documentation |
Creates a criterion that measures the loss given input tensors
x_1
, x_2
and a Tensor
label y
with values 1 or -1.
This is used for measuring whether two inputs are similar or dissimilar,
using the cosine distance, and is typically used for learning nonlinear
embeddings or semi-supervised learning.
The loss function for each sample is:
nn_cosine_embedding_loss(margin = 0, reduction = "mean")
margin |
(float, optional): Should be a number from |
reduction |
(string, optional): Specifies the reduction to apply to the output:
|
\mbox{loss}(x, y) =
\begin{array}{ll}
1 - \cos(x_1, x_2), & \mbox{if } y = 1 \\
\max(0, \cos(x_1, x_2) - \mbox{margin}), & \mbox{if } y = -1
\end{array}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.