Created
January 7, 2021 22:15
-
-
Save kommradHomer/8799f975b4e64f7d64e6eebb4cd7da75 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fasttext | |
import gensim | |
import torch | |
fasttext.load_model("path/to/model/wiki-news-300d-1M.vec") | |
. | |
. | |
## OUT >> | |
## OUT >> ValueError: path/to/embedding/wiki-news-300d-1M.vec has wrong file format! | |
## OUT >> | |
. | |
. | |
## using binary=False is important. | |
##The vectors downloaded from the fastText homepage are not binary | |
temp_model = gensim.models.KeyedVectors.load_word2vec_format("path/to/embedding/wiki-news-300d-1M.vec",binary=False) | |
temp_weights=torch.FloatTensor(temp_model.vectors) | |
print(temp_weights.shape) | |
## OUT >> | |
## OUT >> torch.Size([1000000, 300]) | |
## OUT >> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment