theeluwin/pytorch-sgns

Bug in the Loss Function

Closed this issue · 2 comments

The loss function currently implement is
-(oloss + nloss).mean()

It should be
(-oloss + nloss).mean()

You want to minimize the distance between "positive samples" and maximize the distance between "negative samples".

As you would've noticed, there's .neg() chain at the end of nvectors definition (https://github.com/theeluwin/pytorch-sgns/blob/master/model.py#L72).
But this does seem confusing. I'll fix it to be more verbose someday.

Yes. I noticed it. Thanks for the response.