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

Is there something wrong in the calculating of the TransE loss in function ssaga_model.forward_kg()? #9

Open
RongchuanTang opened this issue Sep 5, 2022 · 4 comments

Comments

@RongchuanTang
Copy link

In function ssaga_model.forward_kg(), neg_losses = self.define_loss([t, t_neg]), what does this mean? Since the pos_loss in the last line is -(h + r -t), should this be calculated as self.define_loss([t_neg, projected_t]), equal to -(h + r - t_neg)? And the target in self.criterion_KG should be set as 1 rather than -1 to make the pos_loss is greater than the neg_loss. Maybe I misunderstood something, could the authors give some detailed explanations, thanks very much!

@ZijieH
Copy link
Contributor

ZijieH commented Sep 6, 2022

Hi Rongchuan,
The define_loss function computes the distance: |t - (h+r)|, where for true triples, the smaller the value, the better, and for negative samples vice versa. Therefore in the margin loss part, we set -1 to make those true triples have smaller distances than those negative samples.

@RongchuanTang
Copy link
Author

Thanks for your reply. I've got it. I got the sign wrong before. But I still have another question. You seem to try to pull h + r close to t and push t_neg far away from t. But in TransE, we usually push h + r away from t_neg. This two ways seem to be equivalent but I wonder if there additional benefit in choosing the first way, lol...😄

@ZijieH
Copy link
Contributor

ZijieH commented Sep 6, 2022

Hi Rongchuan,
In TransE we try to use the marginal loss that takes the input of positive scores and negative scores. You can find the similar reference code here : https://github.com/DeepGraphLearning/KnowledgeGraphEmbedding

@RongchuanTang
Copy link
Author

OK, thanks for that~

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

2 participants