torch.arange default return type is changed in the latest pytorch version
@@ -42,8 +42,8 @@ class SinusoidalPositionalEmbedding(nn.Module):
"""
half_dim = embedding_dim // 2
emb = math.log(10000) / (half_dim - 1)
- emb = torch.exp(torch.arange(half_dim) * -emb)
- emb = torch.arange(num_embeddings).unsqueeze(1) * emb.unsqueeze(0)
+ emb = torch.exp(torch.arange(half_dim, dtype=torch.float) * -emb)
+ emb = torch.arange(num_embeddings, dtype=torch.float).unsqueeze(1) * emb.unsqueeze(0)
emb = torch.cat([torch.sin(emb), torch.cos(emb)], dim=1).view(num_embeddings, -1)
if embedding_dim % 2 == 1:
# zero pad
