Ensure the gensim generate the same Word2Vec model for different runs on the same data

后端 未结 3 771
Happy的楠姐
Happy的楠姐 2020-12-31 08:13

In LDA model generates different topics everytime i train on the same corpus , by setting the np.random.seed(0), the LDA model will always be initialized and tr

3条回答
  •  执念已碎
    2020-12-31 08:39

    As per the docs of Gensim, for executing a fully deterministically-reproducible run, you must also limit the model to a single worker thread, to eliminate ordering jitter from OS thread scheduling.

    A simple parameter edit to your code should do the trick.

    model = Word2Vec(sentences, size=10, window=5, min_count=5, workers=1)
    

提交回复
热议问题