我训练我的doc2vec模型:
data = ["Sentence 1",
"Sentence 2",
"Sentence 3",
"Sentence 4"]
tagged_data = [TaggedDocument(words=word_tokenize(_d.lower()), tags[str(i)])
for i, _d in enumerate(data)]培训部分:
model = Doc2Vec(size=100, window=10, min_count=1, workers=11, alpha=0.025,
min_alpha=0.025, iter=20)
model.build_vocab(tagged_data, update=False)
model.train(tagged_data,epochs=model.iter,total_examples=model.corpus_count)保存模式:
model.save("d2v.model")这是工作。我想在我的词汇和模型中添加一些句子。E.x.:
new_data = ["Sentence 5",
"Sentence 6",
"Sentence 7"]
new_tagged_data=
[TaggedDocument(words=word_tokenize(_d.lower()),tags[str(i+len(data))])
for i,_d in enumerate(new_data)]而不是更新模式:
model.build_vocab(new_tagged_data, update=True)
model.train(new_tagged_data,
epochs=model.iter,total_examples=model.corpus_count)但不起作用。木星紧急关闭,没有回应。我在word2vec模型中使用了同样的方法,而且它很有效!
这有什么问题吗?
发布于 2018-12-04 20:25:41
build_vocab(..., update-True)功能只是在实验上为Word2Vec开发的,还没有为Doc2Vec进行测试/调试。当尝试与Doc2Vec一起使用它时,有一个长时间打开的崩溃错误
https://github.com/RaRe-Technologies/gensim/issues/1019
所以,它还没有得到支持。
另外,还有许多与模型的平衡和矢量兼容性有关的模糊和困难的问题,这些模型都是以这种方式递增训练的,如果可能的话,您应该用混合在一起的完整的新旧数据来重新训练模型,而不是尝试进行小的更新。
https://stackoverflow.com/questions/53616003
复制相似问题