【发布时间】:2017-07-31 17:04:15
【问题描述】:
根据 gensim.models.Word2Vec API reference,“compute_loss”是一个有效的关键字。但是,我收到一条错误消息,指出它是 unexpected keyword。
更新:
GitHub 上的 Word2Vec 类 does have 'compute_loss' 关键字,但我的本地库没有。
我看到 gensim 文档和库彼此偏离。
我发现conda repository中的win-64/gensim-2.2.0-np113py35_0.tar.bz2-文件不是最新的。
但是在使用 conda 卸载 gensim 后,pip install gensim 并没有改变任何东西,因为它仍然无法工作。
显然,GitHub 上的源代码和分布式库不同,但本教程似乎假设代码与 GitHub 上的代码相同。
/更新结束
我关注并下载了tutorial notebook on Word2Vec。
在输入 [25] 中,“训练损失计算”标题后的第一个单元格中,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'
我通过 conda 安装了 gensim 2.2.0,并从 gensim 存储库中获得了一个新的克隆(使用教程笔记本)。我在 Windows 10 上使用 64 位 Python 3.5.3。(Anaconda)
我曾尝试寻找其他有相同遭遇的人,但没有成功。
您知道这是什么原因,以及如何解决这个问题吗?显然,GitHub 上的源代码和分布式库不同,但本教程似乎假设代码与 GitHub 上的代码相同。
我之前也在官方邮件列表中posted the question。
【问题讨论】: