[英]How can I obtain reproducible results using Keras during development?
I followed this link but I can't set PYTHONHASHSEED=0
,or PYTHONHASHSEED=0
, it won't work.我关注了这个链接,但我无法设置PYTHONHASHSEED=0
或PYTHONHASHSEED=0
,它不起作用。 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?谁能帮我得到一个可重复的结果?
You can't reliably to be honest, apparently Keras devs don't seem concerned about that (see this issue ).老实说,你不能可靠,显然 Keras 开发人员似乎并不关心这一点(见这个问题)。
You can find some hacks to maybe do it over there, been trying most of them on collab with no luck though, sorry.你可以找到一些技巧,也许可以在那里做,虽然没有运气,但在合作中尝试了大部分技巧,对不起。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.