I was doing a task using RNN to predict a time series movement.

I want to make my results reproducible. So I strictly followed this post: https://stackoverflow.com/questions/32419510/how-to-get-reproducible-results-in-keras

My code are as follows:

# Seed value
# Apparently you may use different seed values at each stage
seed_value= 0

# 1. Set the `PYTHONHASHSEED` environment variable at a fixed value
import os

# 2. Set the `python` built-in pseudo-random generator at a fixed value
import random

# 3. Set the `numpy` pseudo-random generator at a fixed value
import numpy as np



# 5. Configure a new global `tensorflow` session

# for later versions:
session_conf = tf.compat.v1.ConfigProto(intra_op_parallelism_threads=1, inter_op_parallelism_threads=1)
sess = tf.compat.v1.Session(graph=tf.compat.v1.get_default_graph(), config=session_conf)

However, every time I ran my codes, I still got a different result, what could the reasons be?

  • 1
    $\begingroup$ This question seems to be off-topic (please read the rules). Consider asking programming questions on StackOverflow. $\endgroup$ Jun 22 at 15:19
  • $\begingroup$ @ArayKarjauv I don't think this is a programming question, but OK. $\endgroup$
    – user900476
    Jun 22 at 15:24
  • $\begingroup$ FYI If using GPU, non-random reproducibility is more complicated than that because of random results ordering. $\endgroup$ Jun 22 at 19:14


Browse other questions tagged .