berniwal / swin-transformer-pytorch

Implementation of the Swin Transformer in PyTorch.
https://arxiv.org/pdf/2103.14030.pdf
MIT License
782 stars 125 forks source link

Runtime error #6

Closed QinchengZhang closed 3 years ago

QinchengZhang commented 3 years ago

I'm running an error in your code at line 117 dots += self.pos_embedding[self.relative_indices[:, :, 0], self.relative_indices[:, :, 1]] IndexError: tensors used as indices must be long, byte or bool tensors

berniwal commented 3 years ago

Thank you for reporting the error, it seems that the error occurs for some and upgrading to different numpy version or changing to [self.relative_indices[:, :, 0].type(torch.long), self.relative_indices[:, :, 1].type(torch.long)] solves the issue.

Unfortunately, I could not reproduce the error on my machine therefore it would be useful to know how did you resolve the error in your case and could you tell me more about your configuration, what operating system you use, what numpy, torch and python versions you are using?