0
我也在Gensim支持論壇上對Google進行了研究,但是我找不到一個好答案。Gensim分割錯誤
基本上,我實現用Gensim爲Doc2Vec在線學習,但Gensim不斷拋出我所謂的「分割
隨機誤差請看看我的示例代碼
from gensim.models import Doc2Vec
from gensim.models.doc2vec import LabeledSentence
import random
import logging
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
sentence1 = "this is a test"
sentence2 = "test test 123 test"
sentence3 = "qqq zzz"
sentence4 = "ppp"
sentences = [
LabeledSentence(sentence1.split(), ["p1"]),
LabeledSentence(sentence2.split(), ["p2"])
]
model = Doc2Vec(min_count=1, window=5, size=400, sample=1e-4, negative=5, workers=1)
model.build_vocab(sentences)
for a in range(2):
random.shuffle(sentences)
print([s.tags[0] for s in sentences])
model.train(sentences)
model.save("test.d2v")
new_model = Doc2Vec.load("test.d2v")
new_sentences = [
LabeledSentence(sentence1.split(), ["n1"]),
LabeledSentence(sentence3.split(), ["n2"])
]
new_model.build_vocab(new_sentences, update=True)
for a in range(4):
random.shuffle(new_sentences)
print([s.tags[0] for s in new_sentences])
new_model.train(new_sentences)
這裏是我的錯誤
INFO:gensim.models.word2vec:training model with 1 workers on 7 vocabulary and 400 features, using sg=0 hs=0 sample=0.0001 negative=5 window=5
INFO:gensim.models.word2vec:expecting 2 sentences, matching count from corpus used for vocabulary survey
Segmentation fault
誰能給我解釋一下爲什麼?如何解決這個問題?
謝謝
如何知道我的操作系統,Python或gensim有問題?我使用Docker與python:3映像來運行該代碼(請參閱我的問題)。 –
這些都很難調試 - 但也很罕見,一旦你有正確/最新版本的東西。 Docker鏡像中的OS /版本是什麼?新鮮開始(或卸載/重新安裝所有主要軟件包)是否做出任何更改?你有沒有試過在gensim裏面運行例子來看它們是否工作?採取這些措施是如何縮小問題的範圍。 – gojomo