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 contrastive distillation loss #17

Open
SkrighYZ opened this issue Jan 22, 2024 · 0 comments
Open

Question about contrastive distillation loss #17

SkrighYZ opened this issue Jan 22, 2024 · 0 comments

Comments

@SkrighYZ
Copy link

SkrighYZ commented Jan 22, 2024

Hi,

I have a few questions about the simclr code.

  1. logits = torch.einsum("if, jf -> ij", p, z) / temperature

    It seems that the predicted features (p) are not in the negatives, which is different from what's suggested in the paper (appendix B). I understand that you switch p and z here (for a symmetric loss?)
    distill_loss = (
    simclr_distill_loss_func(p1, p2, frozen_z1, frozen_z2, self.distill_temperature)
    + simclr_distill_loss_func(frozen_z1, frozen_z2, p1, p2, self.distill_temperature)
    ) / 2

    but there is still no comparisons between different samples in p.

  2. In the paper the distillation loss is applied to the two views independently. Based on the code above, does it mean that we should use them jointly to reproduce the result?

  3. logit_mask = torch.ones_like(pos_mask, device=device)
    logit_mask.fill_diagonal_(True)
    logit_mask[:, b:].fill_diagonal_(True)
    logit_mask[b:, :].fill_diagonal_(True)

    The four lines of code here seem to make logit_mask an all-ones matrix. In my understanding we should assign the diagonals to False. Am I missing something?

TIA

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