PyTorch / Gensim - How to load pre-trained word embeddings

后端 未结 6 765
甜味超标
甜味超标 2020-12-01 02:44

I want to load a pre-trained word2vec embedding with gensim into a PyTorch embedding layer.

So my question is, how do I get the embedding weights loaded by gensim in

6条回答
  •  北海茫月
    2020-12-01 03:34

    I think it is easy. Just copy the embedding weight from gensim to the corresponding weight in PyTorch embedding layer.

    You need to make sure two things are correct: first is that the weight shape has to be correct, second is that the weight has to be converted to PyTorch FloatTensor type.

提交回复
热议问题