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

后端 未结 3 707
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:38

    Just a remark on the randomness.

    If one is working with gensim's W2V model and is using Python version >= 3.3, keep in mind that hash randomisation is turned on by default. If you're seeking consistency between two executions, make sure to set the PYTHONHASHSEED environment variable. E.g. when running your code like so PYTHONHASHSEED=123 python3 mycode.py, next time you generate a model (using the same hash seed) it would be the same as previously generated model (provided, that all other randomness control steps are followed, as mentioned above - random state and single worker). See gensim's W2V source and Python docs for details.

提交回复
热议问题