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

Questions about NCEAverage.py #69

Open
LourisXu opened this issue Dec 22, 2021 · 0 comments
Open

Questions about NCEAverage.py #69

LourisXu opened this issue Dec 22, 2021 · 0 comments

Comments

@LourisXu
Copy link

LourisXu commented Dec 22, 2021

Hi, Thanks a lot for sharing this great code.
In NCEAverage.py, the code is shown as the following:

        if idx is None:
             idx = self.multinomial.draw(batchSize * (self.K + 1)).view(batchSize, -1)
             idx.select(1, 0).copy_(y.data)
        # sample
        weight_l = torch.index_select(self.memory_l, 0, idx.view(-1)).detach()
        weight_l = weight_l.view(batchSize, K + 1, inputSize)
        out_ab = torch.bmm(weight_l, ab.view(batchSize, inputSize, 1))

Select batchsize * (K + 1) features from memory bank and then calculate the similarity matrix. How to determine a positive pair and K negative pairs for each sample?

In MoCo, the aug views of the same image, v1 and v2, are a positive pairs, besides,v1 and other k views from the memory bank of the encoder_k are the k negative pairs. In CMC, this seems to be K + 1 negative pairs, because the memory bank is updated late and it seems that it is not guaranteed to obtain the positive pair view of each sample in the same batch.

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