【问题标题】:Doc2Vec __init__() got an unexpected keyword argument 'size'Doc2Vec __init__() 有一个意外的关键字参数“大小”
【发布时间】:2021-09-20 08:29:19
【问题描述】:

像这样实例化 Doc2Vec 模型

mv_tags_doc = [TaggedDocument(words=word_tokenize_clean(D), tags=[str(i)]) for i, D in enumerate(mv_tags_corpus)]

max_epochs = 50
vector_size = 20
alpha = 0.025

model = Doc2Vec(size=vector_size,
                alpha=alpha, 
                min_alpha=0.00025,
                min_count=1,
                dm=0)
  
model.build_vocab(mv_tags_doc)

但出现错误

TypeError: __init__() got an unexpected keyword argument 'size'

【问题讨论】:

    标签: python jupyter-notebook jupyter google-colaboratory doc2vec


    【解决方案1】:

    在您似乎正在使用的最新版本的 Gensim 库中,参数size 现在在任何地方都更加一致的是vector_size。请参阅“迁移到 Gensim 4.0”帮助页面:

    https://github.com/RaRe-Technologies/gensim/wiki/Migrating-from-Gensim-3.x-to-4#1-size-ctr-parameter-is-now-consistently-vector_size-everywhere

    另外,如果您正在咨询任何具有该过时参数名称的在线示例,并且还建议对 min_alphaalpha 进行不必要的说明,那么您所遵循的示例很可能是一个错误的参考其他方式。

    所以,也看看这个答案:My Doc2Vec code, after many loops of training, isn't giving good results. What might be wrong?

    【讨论】:

      猜你喜欢
      • 2014-09-14
      • 2018-04-26
      • 1970-01-01
      • 2019-01-05
      • 2021-10-29
      • 2015-01-27
      • 2016-08-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多