Skip to content

Commit

Permalink
Reduce half of similarity muls after encoding (openai#140)
Browse files Browse the repository at this point in the history
(cAB)^T = c B^T A^T
Saves half of the similarity products in the CLIP model.py after the visual/text encoding stages
  • Loading branch information
or-toledano authored Aug 29, 2021
1 parent 539cdcb commit 3b473b0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion clip/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ def forward(self, image, text):
# cosine similarity as logits
logit_scale = self.logit_scale.exp()
logits_per_image = logit_scale * image_features @ text_features.t()
logits_per_text = logit_scale * text_features @ image_features.t()
logits_per_text = logits_per_image.t()

# shape = [global_batch_size, global_batch_size]
return logits_per_image, logits_per_text
Expand Down

0 comments on commit 3b473b0

Please sign in to comment.