Both files are
presented in text format and almost identical except that word2vec includes
number of vectors and its dimension which is only difference regard to GloVe.
Notes
-
GloVe format (real example can be founded `on Stanford size <https://nlp.stanford.edu/projects/glove/>`_) ::
word1 0.123 0.134 0.532 0.152
word2 0.934 0.412 0.532 0.159
word3 0.334 0.241 0.324 0.188
...
word9 0.334 0.241 0.324 0.188
Word2Vec format (real example can be founded `on w2v old repository <https://code.google.com/archive/p/word2vec/>`_) ::
9 4
word1 0.123 0.134 0.532 0.152
word2 0.934 0.412 0.532 0.159
word3 0.334 0.241 0.324 0.188
...
word9 0.334 0.241 0.324 0.188
手套向量文件格式和word2vec文件格式的唯一区别是在word2vec格式的
.txt
开头的一行<num words> <num dimensions>
否则,向量以相同的方式表示。我们不需要改变向量来改变格式。在
引用您在问题中链接的页面:
在上面的例子中,word2vec的第一行
9 4
告诉我们词汇表中有9个单词,每个单词有4个维度。在TL;DR 因此,要从}行。你可以从文件中推断出来。在
w2v
->;glove
转换:从w2v
中删除{要从
glove
->;w2v
转换:将<num words> <num dimensions>
行添加到glove
。在你可以手动操作,但是gensim提供了一种从一个到另一个的方法。在
相关问题 更多 >
编程相关推荐