Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

about the negative example loss in the Skip-gram-Negative-Sampling algorithm #15

Open
xiaopengguo opened this issue Apr 25, 2021 · 0 comments

Comments

@xiaopengguo
Copy link

xiaopengguo commented Apr 25, 2021

I have learned a lot from this elegant project. Thanks a lots!
Based on the equation in the Skip-gram-Negative-Sampling algorithm below,
微信图片_20210425223243

I think the negative example loss calculated by

negative_score = torch.sum(neg_embeds.bmm(center_embeds.transpose(1, 2)).squeeze(2), 1).view(negs.size(0), -1) # BxK -> Bx1
loss = self.logsigmoid(positive_score) + self.logsigmoid(negative_score)

maybe change to
negative_score = neg_embeds.bmm(center_embeds.transpose(1, 2))
loss = self.logsigmoid(positive_score) + torch.sum(self.logsigmoid(negative_score), 1)
since based on the equation, the negative_socre first goes through a logsigmoid operation, and then sums up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant