我想导入从 tensorflow 创建的词向量并在 gensim 中使用它。
有一种方法gensim.models.KeyedVectors.load_word2vec_format
所以我通过在 Tensorflow 中的训练 wordvec 中遵循完全相同的方式尝试了这种方法,导入到 Gensim
例子:
2 3
字0 -0.000737 -0.002106 0.001851
字1 -0.000878 -0.002106 0.002834
保存文件,然后使用 kwarg binary=False 加载:
model = Word2Vec.load_word2vec_format(filename, binary=False)
但错误喜欢
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?
提高
我怎么解决这个问题?