我正在尝试使用一个预先训练的模型,并添加更多的词汇。我有一个csv文件,其中有一列句子。
import gensim
existing_model_fr = gensim.models.Word2Vec.load('./fr/fr.bin')
new_sentences = gensim.models.word2vec.LineSentence('./data/french.csv')
existing_model_fr.build_vocab(new_sentences, update=True)
existing_model_fr.train(new_sentences, total_examples=existing_model_fr.corpus_count, epochs=5)
existing_model_fr.save('new_model_fr')我在existing_model_fr.train()行中得到了以下错误。我遗漏了什么?
AttributeError跟踪(最近一次调用)在() 列车上的/usr/local/lib/python3.5/dist-packages/gensim/models/word2vec.py (自我、句子、total_examples、total_words、epochs、start_alpha、end_alpha、word_count、queue_factor、report_delay、compute_loss) 863只需调用一次,模型的缓存的iter值应作为时代值提供。864“”-> 865如果self.model_trimmed_post_training: 866引发RuntimeError(“使用model_trimmed_post_training方法丢弃训练参数”) 867如果FAST_VERSION < 0: AttributeError: Word2Vec对象没有属性“model_trimmed_post_training”
发布于 2017-10-28 07:06:33
很可能您正在从gensim的早期版本中加载一个模型,在该版本中没有定义属性model_trimmed_post_training。您可以通过在加载后但在train()之前自行设置属性来解决此问题。
existing_model_fr. model_trimmed_post_training = falsehttps://stackoverflow.com/questions/46985320
复制相似问题