jadore801120 / attention-is-all-you-need-pytorch

A PyTorch implementation of the Transformer model in "Attention is All You Need".
MIT License
8.78k stars 1.97k forks source link

Expected object of scalar type Bool but got scalar type Byte for argument #2 'other' #131

Closed SmallSmallQiu closed 4 years ago

SmallSmallQiu commented 4 years ago

I can't solve this problem, can anyone help?

SmallSmallQiu commented 4 years ago

image

jadore801120 commented 4 years ago

Hello SmallSmallQiu, It is an PyTorch version issue. Sorry for that, I haven't tried on the newest PyTorch version because of hardware issue. So the comparison ops result in torch.bool type, while the subsequent mask is in torch.uint type, which causes the inconsistent types. I think unify the data types to either torch.bool or torch.uint type with op .bool() or .byte() will fix it. I will try to fix it recently. Hope this helps.

Yu-Hsiang

SmallSmallQiu notifications@github.com 於 2019年12月16日 週一 下午10:50 寫道:

[image: image] https://user-images.githubusercontent.com/44115671/70916343-79258600-2056-11ea-8ae4-b11e380e0f07.png

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jadore801120/attention-is-all-you-need-pytorch/issues/131?email_source=notifications&email_token=AA6HAKRI3NZWT76YZ2GZEHLQY6IUJA5CNFSM4J3LB53KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEG66M2Y#issuecomment-566093419, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA6HAKUWSNXPK5GENJ6XGDTQY6IUJANCNFSM4J3LB53A .

SmallSmallQiu commented 4 years ago

Hello SmallSmallQiu, It is an PyTorch version issue. Sorry for that, I haven't tried on the newest PyTorch version because of hardware issue. So the comparison ops result in torch.bool type, while the subsequent mask is in torch.uint type, which causes the inconsistent types. I think unify the data types to either torch.bool or torch.uint type with op .bool() or .byte() will fix it. I will try to fix it recently. Hope this helps. Yu-Hsiang SmallSmallQiu notifications@github.com 於 2019年12月16日 週一 下午10:50 寫道: [image: image] https://user-images.githubusercontent.com/44115671/70916343-79258600-2056-11ea-8ae4-b11e380e0f07.png — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#131?email_source=notifications&email_token=AA6HAKRI3NZWT76YZ2GZEHLQY6IUJA5CNFSM4J3LB53KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEG66M2Y#issuecomment-566093419>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA6HAKUWSNXPK5GENJ6XGDTQY6IUJANCNFSM4J3LB53A . Hello, thank you very much for your timely reply.Your reply lets me know what the problem is and what I should do.I'll lower my version of pytorch and hopefully you'll get the code to run successfully on the latest version of pytorch.

jadore801120 commented 4 years ago

Hello @SmallSmallQiu I just uploaded a new version using torch.bool instead of torch.byte. please take a look at 6c0b653 . Feel free to reopen the issue if the problem still exists.