Skip to content

question about emb loss #49

Description

@256785

def call(self, q_reps, p_reps):
if self.negatives_cross_device:
# This gathers both negatives and positives.
# It could likely be optimized by only gathering negatives.
q_reps = self._dist_gather_tensor(q_reps)
p_reps = self._dist_gather_tensor(p_reps)
scores = self.compute_similarity(q_reps, p_reps) / self.temperature
scores = scores.view(q_reps.size(0), -1)

    target = torch.arange(scores.size(0), device=scores.device, dtype=torch.long)
    target *= (p_reps.size(0) // q_reps.size(0))
    return self.cross_entropy(scores, target)

in the code,does it use ContrastiveLoss following the paper?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions