A user wants to load a pre-trained word2vec embedding with gensim into a PyTorch embedding layer. How to get the embedding weights loaded by gensim into the PyTorch embedding layer?

1.3K    Asked by GayatriJaiteley in Data Science , Asked on Dec 24, 2019
Answered by Gayatri Jaiteley

There is a function from_pretrained() which makes loading an embedding very comfortable. Below is an example of the code


The weights from gensim can be obtained by



Your Answer

Interviews

Parent Categories