Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in tensor size mismatch #22

Open
SURAJ28092001 opened this issue Nov 5, 2022 · 1 comment
Open

Error in tensor size mismatch #22

SURAJ28092001 opened this issue Nov 5, 2022 · 1 comment

Comments

@SURAJ28092001
Copy link

Hi @jacobgil,
I am using this project for my swin transformers but it is giving error showing

     35             # print("a : ",a)
     36             # print(a.size())
---> 37             a = a / a.sum(dim=-1)
     38 
     39             result = torch.matmul(a, result)

RuntimeError: The size of tensor a (49) must match the size of tensor b (64) at non-singleton dimension 1 ```

Please a give a solution for the same
@raphaelattias
Copy link

raphaelattias commented Nov 7, 2022

@SURAJ28092001 Same, I am getting this issue with ViT-8

EDIT: setting keep_dim=True fixes the issue.

a = a / a.sum(dim=-1,keepdim=True)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants