Hi everyone, I am trying to understand if there is a reason why Embedding.from_pretrained()
in current code doesn’t take a padding_idx
option that’s passed through to the constructor. Is that simply missing or is there something subtle going on here?
@classmethod
def from_pretrained(cls, embeddings, freeze=True, sparse=False):
assert embeddings.dim() == 2, \
'Embeddings parameter is expected to be 2-dimensional'
rows, cols = embeddings.shape
embedding = cls(
num_embeddings=rows,
embedding_dim=cols,
_weight=embeddings,
sparse=sparse,
)
embedding.weight.requires_grad = not freeze
return embedding
Thanks!