简体   繁体   中英

How to set random seed in tensorflow

Can someone please tell how to set a random seed in tensor flow? Like in numpy:

np.random.seed(seed = some_number)

I have tried:

with tf.Session() as sess:
tf.set_random_seed(seed = 42) 

but it does not seem to work. Thank you!

To set the global random seed:

tf.random.set_seed(seed)

Where the argument seed is your some_number

From https://www.tensorflow.org/api_docs/python/tf/random/set_seed

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM