如何使用Tensorflow 2.0获得可再现的结果? [英] How do I get reproducible results with Tensorflow 2.0?
问题描述
我已经看到 stackoverflow 有关在keras和TF 1.x中的可重复性.由于它不再具有tf.Session
,我该如何在TF 2.0中执行类似的操作?我知道我仍然可以通过传递诸如tf.keras.initializers.GlorotNormal(seed=10)
之类的东西来设置图种子和该层中每个初始化的种子.但是,我想知道是否还有更方便的方法.
I have seen this FAQ and this stackoverflow about reproducibility in keras and TF 1.x. How do I do something similar in TF 2.0 because it no longer has tf.Session
? I know I could still set the graph seed and the seed for each initialization in the layer by passing something like tf.keras.initializers.GlorotNormal(seed=10)
. However, I am wondering if there is something more convenient.
推荐答案
请考虑在启动时使用tf.random.set_seed(seed)
.在我的用例中,它提供了可重复的结果.
Consider using tf.random.set_seed(seed)
at the startup. In my use cases it provides reproducible results.
这篇关于如何使用Tensorflow 2.0获得可再现的结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!