"git@developer.sourcefind.cn:OpenDAS/vision.git" did not exist on "68b128d5a9ccfe05d64fc1a93e686f8489fd63b9"
Commit 2de93532 authored by Sergey Edunov's avatar Sergey Edunov Committed by Myle Ott
Browse files

torch.arange default return type is changed in the latest pytorch version...

torch.arange default return type is changed in the latest pytorch version https://github.com/pytorch/pytorch/pull/7016
parent fc87eea2
...@@ -42,8 +42,8 @@ class SinusoidalPositionalEmbedding(nn.Module): ...@@ -42,8 +42,8 @@ class SinusoidalPositionalEmbedding(nn.Module):
""" """
half_dim = embedding_dim // 2 half_dim = embedding_dim // 2
emb = math.log(10000) / (half_dim - 1) emb = math.log(10000) / (half_dim - 1)
emb = torch.exp(torch.arange(half_dim) * -emb) emb = torch.exp(torch.arange(half_dim, dtype=torch.float) * -emb)
emb = torch.arange(num_embeddings).unsqueeze(1) * emb.unsqueeze(0) 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) emb = torch.cat([torch.sin(emb), torch.cos(emb)], dim=1).view(num_embeddings, -1)
if embedding_dim % 2 == 1: if embedding_dim % 2 == 1:
# zero pad # zero pad
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment