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

关于Model_MMGCN.py 里的Net类中loss的计算方法 #50

Open
hyc9 opened this issue Mar 28, 2022 · 1 comment
Open

关于Model_MMGCN.py 里的Net类中loss的计算方法 #50

hyc9 opened this issue Mar 28, 2022 · 1 comment

Comments

@hyc9
Copy link

hyc9 commented Mar 28, 2022

您好!在运行您的代码时,我发现在Net类的loss函数中:

def loss(self, user_tensor, item_tensor) :
        user_tensor = user_tensor.view(-1)
        item_tensor = item_tensor.view(-1)
        out = self.forward()
        user_score = out[user_tensor]     
        item_score = out[item_tensor]       # Here
        score = torch.sum(user_score*item_score, dim=1).view(-1, 2)
        loss = -torch.mean(torch.log(torch.sigmoid(torch.matmul(score, self.weight))))
        reg_embedding_loss = (self.id_embedding[user_tensor]**2 + self.id_embedding[item_tensor]**2).mean()+(self.v_gcn.preference**2).mean()
        reg_loss = self.reg_weight * (reg_embedding_loss)
        return loss+reg_loss, reg_loss, loss, reg_embedding_loss, reg_embedding_loss

从仓库中提供的movielens sample数据集来看,#user = 100, #item = 1141, 故out.shape[0]是1241. 然而在代码的dataset写法中,并没有对positive item的index做特殊处理,即范围仍是[0, 1140] , 所以在如上的loss函数中,user[0]和positive item[0]对应着相同的embedding, 此处是否有问题呢?感谢您的回复!

@weiyinwei
Copy link
Owner

您好,感谢您对于我们工作的关注。我们对于user和item是统一编码的,也就是说item是从num_user开始进行编号的。不过对于toy dataset,我并没有单独进行处理。

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