I encountered a problem that tf.set_random_seed
is unable to generate a repeatable value when programming using Tensorflow on python. To be specific,
import tensorflow as tf
sd = 1
tf.set_random_seed(seed = sd)
tf.reset_default_graph()
sess = tf.InteractiveSession()
print(sess.run(tf.random_normal(shape=[1], mean=0, stddev=1)))
the code above outputs [1.3086201]
. Then I ran the whole piece of code again, it doesn't outputs the expected value [1.3086201]
but gives a new [-2.1209881]
.
Why would this happen and how to set a Tensorflow seed?
Aucun commentaire:
Enregistrer un commentaire