Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,8 @@
" # PEpos + k can be represented as a linear function of PEpos.\n",
" pe[:, 0::2] = torch.sin(position * div_term)\n",
" pe[:, 1::2] = torch.cos(position * div_term)\n",
" pe = pe.unsqueeze(0).transpose(0, 1)\n",
" # pe = pe.unsqueeze(0).transpose(0, 1)\n",
" pe = pe.unsqueeze(0)\n",
" self.register_buffer('pe', pe)\n",
"\n",
" def forward(self, x):\n",
Expand All @@ -910,7 +911,7 @@
" x: Tensor\n",
" Output is of the same shape as input with dropout and positional encodings\n",
" \"\"\"\n",
" x = x + self.pe[:x.size(0), :]\n",
" x = x + self.pe[0,:x.size(1), :]\n",
" return self.dropout(x)"
]
},
Expand Down