python-3.x - TypeError: __init__() 在 Node2Vec 中得到了一个意外的关键字参数 'size'
问题描述
我正在嵌入一个带有 Node2Vec 库的图,但我得到这个错误: TypeError: init () got an unexpected keyword argument 'size' to the following code block -
model = node2vec.fit(window=10, min_count=1, batch_words=4)
知道为什么会这样吗?
解决方案
我遇到了完全相同的问题,找不到解决方案。从评论中我尝试重新启动运行时但没有任何改变。
我的代码是:
node2vec = Node2Vec(G)
model = node2vec.fit()
和我得到的错误:
TypeError: __init__() got an unexpected keyword argument 'size'
它直接指向.fit()
我用networkX图尝试过的线,并且用stellargraph(使用EdgeSplitter)它们两者都有相同的错误。我也尝试过设置维度:
node2vec = Node2Vec(G, dimensions=24)
但它也没有奏效。我不知道我还能尝试什么...
编辑:以防万一,完整的错误消息是:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-38-3ccb4a8a103e> in <module>
4
5 node2vec = Node2Vec(G, dimensions=24)
----> 6 model = node2vec.fit()
7 edges_embs = HadamardEmbedder(keyed_vectors=model.wv)
8 train_embeddings = [edges_embs[str(x[0]),str(x[1])] for x in samples_train]
D:\environnements\stel2\lib\site-packages\node2vec\node2vec.py in fit(self, **skip_gram_params)
172 :type skip_gram_params: dict
173 :return: A gensim word2vec model
--> 174 """
175
176 if 'workers' not in skip_gram_params:
TypeError: __init__() got an unexpected keyword argument 'size'
解决方案
解决方案来了:您必须将 gensim 从(在我的情况下)降级4.1.2
到3.8.3
. 我正在使用 node2vec0.4.3
这个问题应该从 4.2 开始修复,但由于某种原因我仍然有它。
https://githubmemory.com/repo/eliorc/node2vec/issues/60
我从adamdingliang的建议中得到了解决方案
推荐阅读
- javascript - 数据表中的 PHP 重定向按钮不起作用
- c# - 如何在 CodeFirst 中使用 WHERE 子句中的 JSON_VALUE 进行类型转换
- sql - SQL 从两个或多个不相关的表中选择所有列
- php - 外部约束失败
- android - 如何为我的 Android 应用程序启用 Google Ads?
- php - 如何在表格中选择一行并在 PHP 中回显
- blender - Blender 命令行导入文件
- elixir - 无法创建 Rumbl.Repo 的数据库:已杀死
- javascript - 到达页面顶部时如何将tr粘贴在表格中间
- c# - 无法解析类型:System.String、System.Private.CoreLib、版本 4.0.0.0 - Asp.net Core (.net core 2.1) 服务器、.NET 4.6.1 客户端