根据gensim.models.Word2VecAPI reference,“compute_loss”是一个有效的关键字。但是,我收到一个错误,说这是一个unexpected keyword
。为什么gensim的Word2Vec不能识别'compute_loss'关键字?
UPDATE:
在GitHub上does have的 'compute_loss' 关键字,但我的本地库中的Word2Vec类没有。 我看到gensim文档和库彼此偏离。 我发现-conda repository中的文件不是最新的。
但是,使用conda卸载gensim后,pip install gensim
没有改变任何东西,因为它仍然不起作用。
显然,GitHub和分布式库上的源代码是不同的,但本教程似乎假定代码与GitHub上的代码相同。 UPDATE
的
/END我也跟着下载的tutorial notebook on Word2Vec。
在输入[25]中,“Training Loss Computation”标题后的第一个单元格中,我在Word2Vec类的初始化程序中遇到错误。
输入:
# instantiating and training the Word2Vec model
model_with_loss = gensim.models.Word2Vec(sentences, min_count=1,
compute_loss=True, hs=0, sg=1, seed=42)
# getting the training loss value
training_loss = model_with_loss.get_latest_training_loss()
print(training_loss)
输出:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-25-c2933abf4b08> in <module>()
1 # instantiating and training the Word2Vec model
----> 2 model_with_loss = gensim.models.Word2Vec(sentences, min_count=1, compute_loss=True, hs=0, sg=1, seed=42)
3
4 # getting the training loss value
5 training_loss = model_with_loss.get_latest_training_loss()
TypeError: __init__() got an unexpected keyword argument 'compute_loss'
我必须通过畅达安装gensim 2.2.0,并有从gensim库(与教程笔记本电脑)的新新克隆。我在Windows 10上使用64位Python 3.5.3。(Anaconda)
我试图寻找其他人遇到同样的遭遇,但我没有成功。
你知道这个的原因,以及如何解决这个问题吗?显然,GitHub和分布式库上的源代码是不同的,但本教程似乎假设代码与GitHub上的代码相同。
我以前也在官方邮件列表中的posted the question。