Which seeds have to be set where to realize 100% r

2019-01-12 06:33发布

In a general tensorflow setup like

model = construct_model()
with tf.Session() as sess:
    train_model(sess)

Where construct_model() contains the model definition including random initialization of weights (tf.truncated_normal) and train_model(sess) executes the training of the model -

Which seeds do I have to set where to ensure 100% reproducibility between repeated runs of the code snippet above? The tensorflow documentation at

https://www.tensorflow.org/api_docs/python/constant_op/random_tensors#set_random_seed

may be concise, but left me a bit confused. I tried

tf.set_random_seed(1234)
model = construct_model()
    with tf.Session() as sess:
        train_model(sess)

But got different results each time.

1条回答
我想做一个坏孩纸
2楼-- · 2019-01-12 07:19

One possible reason is that when constructing the model, there are some code using numpy.random module. So maybe you can try to set the seed for numpy, too.

查看更多
登录 后发表回答