WangFeng18/Swin-Transformer

IndexError: tensors used as indices must be long, byte or bool tensors

Opened this issue · 3 comments

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

I get the same error

90 cord = torch.tensor(np.array([[i, j] for i in range(self.window_size) for j in range(self.window_size)])) --->

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)