Skip to content
Snippets Groups Projects
Commit a79359f9 authored by Léo Schneider's avatar Léo Schneider
Browse files

test cossim

parent b29d68ab
No related branches found
No related tags found
No related merge requests found
......@@ -25,16 +25,17 @@ class PositionalEncoding(nn.Module):
pe = torch.zeros(max_len, 1, d_model)
pe[:, 0, 0::2] = torch.sin(position * div_term)
pe[:, 0, 1::2] = torch.cos(position * div_term)
print(d_model, max_len)
self.register_buffer('pe', pe)
def forward(self, x):
print(x.size())
x = torch.permute(x, (1, 0, 2))
"""
Arguments:
x: Tensor, shape ``[seq_len, batch_size, embedding_dim]``
"""
print(self.pe[:x.size(0)].size())
x = x + self.pe[:x.size(0)]
return self.dropout(x)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment