错误方法:
for topic in range(15):
lda_model = gensim.models.LdaMulticore(corpus=corpus, num_topics=topic + 1, id2word=id2word, random_state=100,chunksize=100, passes=10, per_word_topics=True)
model_list.append(lda_model)
coherencemodel = CoherenceModel(model=lda_model, texts=train, dictionary=id2word, coherence='c_v')
coherence_values.append(round(coherencemodel.get_coherence(), 3))
错误提示:
self._semlock = _multiprocessing.SemLock._rebuild(*state)
FileNotFoundError: [Errno 2] No such file or directory
修改方法:
加入
from multiprocessing import Process,Queue,set_start_method,get_context
set_start_method('fork')
正确方法:
from multiprocessing import Process,Queue,set_start_method,get_context
if __name__ == '__main__':
set_start_method('fork')
for topic in range(15):
lda_model = gensim.models.LdaMulticore(corpus=corpus, num_topics=topic + 1, id2word=id2word, random_state=100, chunksize=100, passes=10, per_word_topics=True)
model_list.append(lda_model)
coherencemodel = CoherenceModel(model=lda_model, texts=train, dictionary=id2word, coherence='c_v')
coherence_values.append(round(coherencemodel.get_coherence(), 3))
参考链接:https://www.cnblogs.com/tortoise512/p/14706937.html