Reputation: 21
I followed this link but I can't set PYTHONHASHSEED=0
,or PYTHONHASHSEED=0
, it won't work. My code is as follows:
import tensorflow as tf
import numpy as np
import random as rn
sd = 1
np.random.seed(sd)
rn.seed(sd)
config = tf.ConfigProto(intra_op_parallelism_threads=1,inter_op_parallelism_threads=1)
from keras import backend as K
tf.set_random_seed(sd)
sess = tf.Session(graph=tf.get_default_graph(), config=config)
K.set_session(sess)
import os
os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"
os.environ["CUDA_VISIBLE_DEVICES"] = ""
os.environ['PYTHONHASHSEED'] = '0'
Every time I ran the code, it gave different results. My environment consists of
Can anyone help me get a reproducible result?
Upvotes: 2
Views: 102
Reputation: 24701
You can't reliably to be honest, apparently Keras devs don't seem concerned about that (see this issue).
You can find some hacks to maybe do it over there, been trying most of them on collab with no luck though, sorry.
Upvotes: 1