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

question about the code #6

Closed
liuxingbin opened this issue Apr 27, 2021 · 2 comments
Closed

question about the code #6

liuxingbin opened this issue Apr 27, 2021 · 2 comments

Comments

@liuxingbin
Copy link

This is an excellent work, but i have several question about the code:

  1. in training/train.py Line32. the dimension of q and k are supposed to be (n,c). I think the right code is l_pos = torch.einsum('nc,nc->n', [q, k]).unsqueeze(-1)
  2. the update memory bank seems not correspond to the original paper( sec3.3, eq5). I am confused about torch.mul(torch.mean(torch.mul(p_qd,l_neg),dim=0),d_norm) in Line 63, and line64 torch.div(g,torch.norm(d,dim=0))

Kindly hope you can help me understand. Thank you very much.

@wang3702
Copy link
Collaborator

Thanks a lot for your interest in our work!
1 First, we used the matrix multiplying in a different way in the implementation, where the other examples in the same batch are also regarded as negative in our implementation.
2 This is a time-efficient implementation, it is the same as that in our paper. Instead, you can also simply use the SGD optimizer to optimize the memory bank by taking the negative contrastive loss with a smaller temperature.

@liuxingbin
Copy link
Author

Thanks a lot for your interest in our work!
1 First, we used the matrix multiplying in a different way in the implementation, where the other examples in the same batch are also regarded as negative in our implementation.
2 This is a time-efficient implementation, it is the same as that in our paper. Instead, you can also simply use the SGD optimizer to optimize the memory bank by taking the negative contrastive loss with a smaller temperature.

Thanks, that helps me a lot.

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