From a79359f9d726e4b07e495c5d2c4a5695a31fb38a Mon Sep 17 00:00:00 2001 From: lschneider <leo.schneider@univ-lyon1.fr> Date: Thu, 19 Sep 2024 14:54:43 +0200 Subject: [PATCH] test cossim --- model_custom.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/model_custom.py b/model_custom.py index ce6bb1c..0a67502 100644 --- a/model_custom.py +++ b/model_custom.py @@ -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) -- GitLab