Fails to fix the seed value in LDA model in gensim
<p>When using LDA model, I get different topics each time and I want to replicate the same set. I have searched for the similar question in Google such as <a href="https://groups.google.com/forum/#!topic/gensim/s1EiOUsqT8s" rel="nofollow">this</a>.</p>

<p>I fix the seed as shown in the article by <code>num.random.seed(1000)</code> but it doesn't work. I read the <code>ldamodel.py</code> and find the code below:</p>

<pre><code>def get_random_state(seed):

    """
    Turn seed into a np.random.RandomState instance.
    Method originally from maciejkula/glove-python, and written by @joshloyal
    """
     if seed is None or seed is numpy.random:
         return numpy.random.mtrand._rand
     if isinstance(seed, (numbers.Integral, numpy.integer)):
         return numpy.random.RandomState(seed)
     if isinstance(seed, numpy.random.RandomState):
        return seed
     raise ValueError('%r cannot be used to seed a numpy.random.RandomState'
                      ' instance' % seed)
</code></pre>

<p>So I use the code:</p>

<pre><code>lda = models.LdaModel(
    corpus_tfidf,
    id2word=dic,
    num_topics=2,
    random_state=numpy.random.RandomState(10)
)
</code></pre>

<p>But it's still not working.</p>

<p>The dictionary generated by <code>corpora.Dictionary</code> may be different to the same corpus(such as same words but different order).So one should fix the dictionary as well as seed to get tht same topic each time.The code below may help to fix the dictionary:</p>

<pre><code>dic = corpora.Dictionary(corpus)
dic.save("filename")
dic=corpora.Dictionary.load("filename")
</code></pre>

python numpy gensim