Ama*_*ani 2 python-2.7 gensim word2vec
我一直在尝试运行一个示例,说明如何从 python 的 gensim 库中使用 word2vec,但我不断收到此错误
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Run Code Online (Sandbox Code Playgroud)
这是我的代码,它只是一个简单的例子:
from gensim.models import Word2Vec
sentences = [['first', 'sentence'], ['second', 'sentence']]
# train word2vec on the two sentences
model = Word2Vec(sentences, min_count=1)
Run Code Online (Sandbox Code Playgroud)
注意:我已经确保安装了 gensim 及其所有依赖项。
我也遇到了这个问题。对我来说,这个错误显然有另一个背景:
通常,我将文本数据收集到dtype=np.str. 当我将 numpy-text-array 加载到 gensim-model 中时,我收到了您描述的错误。实际上,将数组存储在普通的 python 中 -list而不是诀窍..
也许这有助于其他人遇到这个问题。
| 归档时间: |
|
| 查看次数: |
1103 次 |
| 最近记录: |