简体   繁体   English

"如何使用 python gensim 训练我的模型"

[英]how can I train my model using python gensim

I am trying to train my model and when I write these codes :我正在尝试训练我的模型,当我编写这些代码时:

for epoch in range(max_epochs):
    model.train(tagged_data,
                total_examples=model.corpus_count,
                epochs=model.iter)

You're likely copying some outdated example code.您可能正在复制一些过时的示例代码。 For example:例如:

  • recent versions of Gensim don't have an .iter property on the Doc2Vec model最新版本的 Gensim 在Doc2Vec模型上没有.iter属性
  • it's almost always a bad idea to be calling train() multiple times in your own epochs loop - especially as a beginner just trying to get things working在你自己的epochs循环中多次调用train()几乎总是一个坏主意 - 特别是作为一个试图让事情正常工作的初学者

So: don't copy whatever source you're copying.所以:不要复制你正在复制的任何来源。 It's not only out-of-date, it's suggesting something (the train() calls in a loop) that was never a great idea.它不仅过时了,而且暗示了一些从来都不是一个好主意的东西( train()在循环中调用)。

Instead, base your work on better examples, like the intro tutorial in the Gensim docs:相反,将您的工作基于更好的示例,例如 Gensim 文档中的介绍教程:

https://radimrehurek.com/gensim/auto_examples/tutorials/run_doc2vec_lee.html https://radimrehurek.com/gensim/auto_examples/tutorials/run_doc2vec_lee.html

将 model.iter 更改为 model.epochs 即 model.train(tagged_data, total_examples=model.corpus_count, epochs=model.epochs)

"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM