gensim - Word2vec online training - AttributeError: 'Word2Vec' object has no attribute 'model_trimmed_post_training
gensim - Word2vec online training - AttributeError: 'Word2Vec' object has no attribute 'model_trimmed_post_training
我正在尝试使用预训练模型并向其添加额外的词汇。我有一个包含 1 列句子的 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 Traceback (most recent call last) in ()
/usr/local/lib/python3.5/dist-packages/gensim/models/word2vec.py in
train(self, sentences, total_examples, total_words, epochs,
start_alpha, end_alpha, word_count, queue_factor, report_delay,
compute_loss) 863 is only called once, the model's cached iter value
should be supplied as epochs value. 864 """ --> 865 if
self.model_trimmed_post_training: 866 raise RuntimeError("Parameters
for training were discarded using model_trimmed_post_training method")
867 if FAST_VERSION < 0:
AttributeError: 'Word2Vec' object has no attribute
'model_trimmed_post_training'
您可能正在从未定义 属性 model_trimmed_post_training
的较早版本的 gensim 加载模型。您可以通过在加载之后 train()
:
之前自己设置 属性 来解决此问题
existing_model_fr. model_trimmed_post_training = false
我正在尝试使用预训练模型并向其添加额外的词汇。我有一个包含 1 列句子的 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 Traceback (most recent call last) in ()
/usr/local/lib/python3.5/dist-packages/gensim/models/word2vec.py in train(self, sentences, total_examples, total_words, epochs, start_alpha, end_alpha, word_count, queue_factor, report_delay, compute_loss) 863 is only called once, the model's cached iter value should be supplied as epochs value. 864 """ --> 865 if self.model_trimmed_post_training: 866 raise RuntimeError("Parameters for training were discarded using model_trimmed_post_training method") 867 if FAST_VERSION < 0:
AttributeError: 'Word2Vec' object has no attribute 'model_trimmed_post_training'
您可能正在从未定义 属性 model_trimmed_post_training
的较早版本的 gensim 加载模型。您可以通过在加载之后 train()
:
existing_model_fr. model_trimmed_post_training = false