简体   繁体   English

如何在开发过程中使用 Keras 获得可重现的结果?

[英]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=0PYTHONHASHSEED=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我的环境包括

  • Keras 2.2.4 Keras 2.2.4
  • with tensorflow-CPU 1.14.0 as backend.使用 tensorflow-CPU 1.14.0 作为后端。
  • python 3.7 python 3.7
  • windows 10 windows 10

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.

相关问题 对于使用数据增强进行图像分类的卷积神经网络,如何在 keras 中获得可重现的结果? - How can I get reproducible results in keras for a convolutional neural network using data augmentation for image classification? 如何使用 Keras 获得可重现的结果? - How do I get reproducible results with Keras? 如何在 keras 中获得可重现的结果 - How to get reproducible results in keras 为什么即使我设置了随机种子,我也无法在 Keras 中获得可重现的结果? - Why can't I get reproducible results in Keras even though I set the random seeds? 在 Python 中使用 Keras 和 TensorFlow 无法重现结果 - Results not reproducible with Keras and TensorFlow in Python 每次我得到不同的结果,我怎样才能让我的代码可重现? - I get different results every time, how can I make my code reproducible? 构建Keras项目以在GPU中实现可重现的结果 - Structuring a Keras project to achieve reproducible results in GPU Keras:可重现的结果CPU上的简单MLP - Keras: Reproducible Results Simple MLP on CPU 无法使用 Keras CNN Model 获得可重现的结果 - Cannot get Reproducible Results with Keras CNN Model 如何在CNN模型中使用tensorflow-gpu获得可重现的结果? - How to get reproducible results using tensorflow-gpu in CNN model?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM