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