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?
Isnt padding_idx special in the sense that we do not apply gradients to it? Or is the embedding corresponding to the padding index also updated when we use an optimizer?
Thanks for the pointer. I had the confusion as I was using SparseEmbeddings with Pytorch 0.3.0. There the embedding corresponding to padding index was also updated. The bug was fixed in 0.3.1. Adding it here in case someone else stumbles across it https://github.com/pytorch/pytorch/issues/3506
Is there an easy way to do this in a general way? I’m doing seq2seq where the inputs are a set of variables rather than a single value. I’ve got a special start of sequence set value that I’d like to use to trigger operations within the forward, but I’m hoping that I can somehow prevent the weights from being updated.
The approach I’m planning for now is to make the sequence all 0, with the target also 0, and hope that the net chooses the easy path of just connecting input to output, but ideally i’d like to just not update the weights at all.
I’m also curious about the implementation here within the embedding layer. Is there corresponding code preventing the rest of the net from updating? Or does padding index just prevent the embedding from updating?