最近在使用Word2Vec时发现一个奇怪的问题,那就是每次运行出来的结果不一致,这就是得程序复现带来了很多麻烦。多方查阅资料后终于解决了这个难题,下面说一下我的解决方案。
查阅Word2Vec的官方文档,在seed参数哪里可以发现这样的解释:
seed (int) – Seed for the random number generator. Initial vectors for each word are seeded with a hash of the concatenation of word + str(seed)