Open FrankWork opened 6 years ago
This part of the xmb
is used for the learned positional encoding.
An embedding vector is associated by the network to each position of the input and this vector is then added to the corresponding word embedding during the forward pass of the network.
def forward(self, x):
x = x.view(-1, x.size(-2), x.size(-1))
e = self.embed(x)
h = e.sum(dim=2)
for block in self.h:
h = block(h)
return h
The line h = e.sum(dim = 2)
do this addition.
@rodgzilla Thank you! You saved my day!
Mark