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

想请教一下损失函数的计算问题 #3

Closed
workspace-for-cross-modality opened this issue Mar 17, 2021 · 4 comments
Closed

想请教一下损失函数的计算问题 #3

workspace-for-cross-modality opened this issue Mar 17, 2021 · 4 comments

Comments

@workspace-for-cross-modality

您好,我在查看代码的时候,发现和moco相比,损失函数计算的label从全零变成了代码中的torch.arange,请问这样做是什么含义呢,期待您的解答。
labels = torch.arange(choose_match, choose_match + cur_batch_size, dtype=torch.long).cuda()

@wang3702
Copy link
Collaborator

wang3702 commented Mar 17, 2021

您好,这是因为我们同时也用了batch内的其他样本做了similarity calculation,所以如果您查看代码会发现在

k = concat_all_gather(k)

我们做了一个矩阵相乘,所以这会导致我们的对应label实际上是在这个矩阵的diagonal上。
另外希望下次用英文提问,这样其他研究者遇到同样的问题就可以直接查看issue曾经的问题了。

@workspace-for-cross-modality
Copy link
Author

非常感谢您的回答,接受您的建议,以后会用英文提问。

@LetheSec
Copy link

您好,这是因为我们同时也用了batch内的其他样本做了similarity calculation,所以如果您查看代码会发现在

k = concat_all_gather(k)

我们做了一个矩阵相乘,所以这会导致我们的对应label实际上是在这个矩阵的diagonal上。
另外希望下次用英文提问,这样其他研究者遇到同样的问题就可以直接查看issue曾经的问题了。

Why to do a matrix multiplication here, rather than do like MoCo?

@wang3702
Copy link
Collaborator

We found it's better to avoid collapsing.

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

3 participants