[GH-ISSUE #420] Dimension Discrepancy in VisionTransformer? #360

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

Originally created by @Shiran-Yuan on GitHub (Jan 18, 2024).
Original GitHub issue: https://github.com/openai/CLIP/issues/420

In line 227 of clip/model.py there is:

x = torch.cat([self.class_embedding.to(x.dtype) + torch.zeros(x.shape[0], 1, x.shape[-1], dtype=x.dtype, device=x.device), x], dim=1) # shape = [*, grid ** 2 + 1, width].

But this seems impossible, because self.class_embedding is a parameter vector, while torch.zeros(x.shape[0], 1, x.shape[-1]) is a order-3 tensor...

Am I missing something here?

Originally created by @Shiran-Yuan on GitHub (Jan 18, 2024). Original GitHub issue: https://github.com/openai/CLIP/issues/420 In line 227 of clip/model.py there is: `x = torch.cat([self.class_embedding.to(x.dtype) + torch.zeros(x.shape[0], 1, x.shape[-1], dtype=x.dtype, device=x.device), x], dim=1) # shape = [*, grid ** 2 + 1, width]`. But this seems impossible, because self.class_embedding is a parameter vector, while torch.zeros(x.shape[0], 1, x.shape[-1]) is a order-3 tensor... Am I missing something here?
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#360
No description provided.