Hi,
After I created nn.Embedding object and change the weights manually, the values at the padding index also changed and the result of the embedding is not what I wanted. Don’t you think that in the mechanism of nn.Embedding, even though the initialization value is changed manually, the values at the padding should output 0s?
Following is the example code I tried:
embed = nn.Embedding(5,10, padding_idx=4)
initrange = 0.5
embed.weight.data.uniform_(-initrange, initrange)
print embed(Variable(torch.LongTensor([4])))
print embed(Variable(torch.LongTensor([4])))

Variable containing:
-0.2718 -0.1496  0.2677 -0.3810 -0.3220 -0.4013  0.2528  0.0429  0.1287 -0.3817
[torch.FloatTensor of size 1x10]