CLIP icon indicating copy to clipboard operation
CLIP copied to clipboard

Cosine Similarity Calculation and Number Range Inquiry

Open Externalhappy opened this issue 2 years ago • 0 comments

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?

Externalhappy avatar Aug 25 '23 14:08 Externalhappy