About the implementation of HingeEmbeddingLoss

Hi, I try to use this HingeEmbeddingLoss however I did not understand how it works, and I think it’s different from wiki

And I run a little code and still could not understand how it works.

In [36]: x = torch.tensor([0.5, -0.5])

In [37]: y = torch.tensor([1.0, -1.0])

In [38]: torch.nn.HingeEmbeddingLoss(reduction='none')(x,y)
Out[38]: tensor([0.5000, 1.5000])

It seems it tries to make

  • x_n to -inf when y_n==1
  • x_n to be greater than 1 when y_n==-1

But neither of them are making x_n close to y_n.

Could someone help me with this?

  1. Does x_n have to be between [-1,1]?
  2. IMHO, the signs of y_n should be swapped in the doc
    image

Or just follows the one on Wiki.