IndexError: tensors used as indices must be long, byte or bool tensors
Opened this issue · 3 comments
intelljames commented
in relative_embedding(self)
91 relation = cord[:, None, :] - cord[None, :, :] + self.window_size -1
92 # negative is allowed
---> 93 return self.relative_position_params[:, relation[:,:,0], relation[:,:,1]]
94
95 class Block(nn.Module):
IndexError: tensors used as indices must be long, byte or bool tensors
directly run the SwinTransformer.py
gaiyi7788 commented
I get the same error
TangYong1975 commented
90 cord = torch.tensor(np.array([[i, j] for i in range(self.window_size) for j in range(self.window_size)])) --->
TangYong1975 commented
90 cord = torch.tensor(np.array([[i, j] for i in range(self.window_size) for j in range(self.window_size)])).type(torch.long)