[GH-ISSUE #383] Cosine Similarity Calculation and Number Range Inquiry #328

Open
opened 2026-10-31 21:13:56 +00:00 by bsakaguchi · 0 comments
Owner

Originally created by @Externalhappy on GitHub (Aug 25, 2023).
Original GitHub issue: https://github.com/openai/CLIP/issues/383

So, if we calculate the similarity using ,
similarity = F.cosine_similarity(x, y)
without normalizing the image and text features, the computed cosine similarity will have the same output as

x = x / x.norm(dim=-1, keepdim=True) 
y = y / y.norm(dim=-1, keepdim=True)
similarity = x @y.T

Is that correct?

Originally created by @Externalhappy on GitHub (Aug 25, 2023). Original GitHub issue: https://github.com/openai/CLIP/issues/383 So, if we calculate the similarity using , `similarity = F.cosine_similarity(x, y) ` without normalizing the image and text features, the computed cosine similarity will have the same output as ``` x = x / x.norm(dim=-1, keepdim=True) y = y / y.norm(dim=-1, keepdim=True) similarity = x @y.T ``` Is that correct?
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
openai/CLIP#328
No description provided.