I'm attempting to upgrade to tensorflow version 1.0 but have come to find that I'm not able to reproduce my earlier output because the random number generator seems to be different. I need to be able to reproduce my results so I always set the seed to a constant value.
import tensorflow as tf
with tf.Graph().as_default():
tf.set_random_seed(1)
a = tf.get_variable('a', 1)
with tf.Session() as sess:
tf.global_variables_initializer().run()
print('TensorFlow version: {0}'.format(tf.__version__))
print(sess.run(a))
Output:
TensorFlow version: 0.12.1
[-0.39702964]
TensorFlow version: 1.0.1
[0.96574152]
I'm running python v3.5.2 on windows x64. I don't see anything in the Transitioning document that describes this difference. Is there any way to reproduce my earlier results after upgrading?
The most likely culprit is that the number of ops generated before the random op created by the initializer is changing. If you don't set a per-op seed, TensorFlow picks a seed based on the integer id of the random op, which is just the number of ops created before that point. You may have to override the initializer passed to tf.get_variable
manually if you want to test this by setting an explicit seed.
In general, we don't promise random number consistency between different versions of TensorFlow. We do try to document when they change, but that's only useful if you set per-op seeds given that we do not try to document when the numbers of ops change. The relevant bit of that link is
Random numbers: The specific random numbers computed by the random ops may change at any time: users should rely only on approximately correct distributions and statistical strength, not the specific bits computed. However, we will make changes to random bits rarely and ideally never for patch releases, and all such intended changes will be documented.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With