use*_*492 8 python gensim word2vec
我试图通过将来自google word2vec网站(freebase-vectors-skipgram1000.bin.gz)的预训练.bin文件加载到word2vec的gensim实现中来开始.模型加载很好,
用...
model = word2vec.Word2Vec.load_word2vec_format('...../free....-en.bin', binary= True)
Run Code Online (Sandbox Code Playgroud)
并创造一个
>>> print model
<gensim.models.word2vec.Word2Vec object at 0x105d87f50>
Run Code Online (Sandbox Code Playgroud)
但是当我运行最相似的功能时.它无法找到词汇中的单词.我的错误代码如下.
我出错的任何想法?
>>> model.most_similar(['girl', 'father'], ['boy'], topn=3)
2013-10-11 10:22:00,562 : WARNING : word ‘girl’ not in vocabulary; ignoring it
2013-10-11 10:22:00,562 : WARNING : word ‘father’ not in vocabulary; ignoring it
2013-10-11 10:22:00,563 : WARNING : word ‘boy’ not in vocabulary; ignoring it
Traceback (most recent call last):
File “”, line 1, in
File “/....../anaconda/python.app/Contents/lib/python2.7/site-packages/gensim-0.8.7/py2.7.egg/gensim/models/word2vec.py”, line 312, in most_similar
raise ValueError(“cannot compute similarity with no input”)
ValueError: cannot compute similarity with no input
Run Code Online (Sandbox Code Playgroud)
小智 7
'...../free ....- en.bin'中的单词的形式为
en/boardwalk_chapel en/mutsu_munemitsu en/goffstown en/yaw_axis en/john_e_fogarty_international_center en/francielle_manoel_alberto en/shinji_harada
所以,当你寻找'女孩'时,它就不存在了
| 归档时间: |
|
| 查看次数: |
2734 次 |
| 最近记录: |