fairseq icon indicating copy to clipboard operation
fairseq copied to clipboard

Is the padding use zero-embedding?

Open Zrachel opened this issue 9 years ago • 1 comments

As Data.py shows you used padding to get a [batchsize, max_sentence_length] token_input (in class PaddingCollater)

And in Fconv.py, you use Embedding without specifying the embedding of <pad> is an all zero vector.

Am I missing something? Or should padding be zero-embedding? Or doesn't matter?

Thanks.

Zrachel avatar Oct 23 '17 07:10 Zrachel

We pass the padding index to nn.Embedding here: https://github.com/facebookresearch/fairseq-py/blob/84b82dc6d49f386675aee11b26eced623f24db40/fairseq/models/fconv.py#L405

nn.Embedding then automatically replaces this index with zeros.

myleott avatar Oct 23 '17 16:10 myleott