I want to import word vecters created from tensorflow and utilize it at gensim.
there is a method gensim.models.KeyedVectors.load_word2vec_format
so I tried this method by following exactly the same way in Training wordvec in Tensorflow, importing to Gensim
Example:
2 3
word0 -0.000737 -0.002106 0.001851
word1 -0.000878 -0.002106 0.002834
Save the file and then load with kwarg binary=False:
model = Word2Vec.load_word2vec_format(filename, binary=False)
but error like
Traceback (most recent call last):
File "<pyshell#12>", line 1, in <module>
model=gensim.models.KeyedVectors.load_word2vec_format('test.w2v')
File "C:\Users\cbj\Anaconda3\lib\site-packages\gensim\models\keyedvectors.py", line 243, in load_word2vec_format
raise EOFError("unexpected end of input; is count incorrect or file otherwise damaged?")
EOFError: unexpected end of input; is count incorrect or file otherwise damaged?
raised
how can I solve this problem?
This error is raised when the number of vector data doesn't match the number you provided at the first line.
If the first line wrote 2 3
, you should have exactly 2
lines below. Make sure that there's no empty line at the end of your file and of course some where in your file.