mirror of
https://github.com/openai/CLIP.git
synced 2026-11-05 01:37:26 +00:00
[GH-ISSUE #84] Why calculate logits_per_image and logits_per_text separately. #77
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
openai/CLIP#77
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @vinson2233 on GitHub (Apr 8, 2021).
Original GitHub issue: https://github.com/openai/CLIP/issues/84
Just a quick question on calculating the logits.
https://github.com/openai/CLIP/blob/main/clip/model.py line 363
Let
BS = Batch_size
A = image_features is matrix with dimension BS x 512
B = text_features is matrix with dimension BS x 512
x' is transpose of x
Then AxB' = (BxA')'
Is there any reason to not writing logits_per_text simply as the transpose of logits_per_image?
Also in the paper you only calculate the logits once
logits = np.dot(I_e, T_e.T) * np.exp(t)
Thanks
@jongwook commented on GitHub (Apr 8, 2021):
That's correct, no need to do the same calculation twice. The two lines were remnant of distributed training where the transposed matrices were all-gathered tensors.
@vinson2233 commented on GitHub (Apr 8, 2021):
I see, thanks :)