title: How to get reproducible result when running Keras with Tensorflow backend
body: <p>Every time I run LSTM network with Keras in jupyter notebook, I got a different result, and I have googled a lot, and I have tried some different solutions, but none of they are work, here are some solutions I tried:</p>
  
  <ol>
  <li><p>set numpy random seed</p>
  
  <p><code>random_seed=2017 
  from numpy.random import seed 
  seed(random_seed)</code></p></li>
  <li><p>set tensorflow random seed</p>
  
  <p><code>from tensorflow import set_random_seed
  set_random_seed(random_seed)</code></p></li>
  <li><p>set build-in random seed</p>
  
  <p><code>import random
  random.seed(random_seed)</code></p></li>
  <li><p>set PYTHONHASHSEED</p>
  
  <p><code>import os
  os.environ['PYTHONHASHSEED'] = '0'</code></p></li>
  <li><p>add PYTHONHASHSEED in jupyter notebook kernel.json </p>
  
  <p><code>{
   "language": "python",
   "display_name": "Python 3",
   "env": {"PYTHONHASHSEED": "0"},
   "argv": [
    "python",
    "-m",
    "ipykernel_launcher",
    "-f",
    "{connection_file}"
   ]
  }</code></p></li>
  </ol>
  
  <p>and the version of my env is:</p>
  
  <pre><code>Keras: 2.0.6
  Tensorflow: 1.2.1
  CPU or GPU: CPU
  </code></pre>
  
  <p>and this is my code:</p>
  
  <pre><code>model = Sequential()
  model.add(LSTM(16, input_shape=(time_steps,nb_features), return_sequences=True))
  model.add(LSTM(16, input_shape=(time_steps,nb_features), return_sequences=False))
  model.add(Dense(8,activation='relu'))        
  model.add(Dense(1,activation='linear'))
  model.compile(loss='mse',optimizer='adam')
  </code></pre>