我正在尝试生成N组独立的随机数。我有一个简单的代码,显示3组10个随机数的问题。我注意到,即使我使用tf.set_random_seed来设置种子,但不同运行的结果看起来也不相同。任何帮助或评论,我们将不胜感激。
(py3p6) bash-3.2$ cat test.py
import tensorflow as tf
for i in range(3):
tf.set_random_seed(1234)
generate = tf.random_uniform((10,), 0, 10)
with tf.Session() as sess:
b = sess.run(generate)
print(b)
Run Code Online (Sandbox Code Playgroud)
这是代码的输出:
# output :
[9.604688 5.811516 6.4159 9.621765 0.5434954 4.1893444 5.8865128
7.9785547 8.296125 8.388672 ]
[8.559105 3.2390785 6.447526 8.316823 1.6297233 1.4103293 2.647568
2.954973 6.5975866 7.494894 ]
[2.0277488 6.6134906 0.7579422 4.6359386 6.97507 3.3192968 2.866236
2.2205782 6.7940736 7.2391043]
Run Code Online (Sandbox Code Playgroud)
我想要类似的东西
[9.604688 5.811516 6.4159 9.621765 0.5434954 4.1893444 5.8865128
7.9785547 8.296125 8.388672 ]
[9.604688 5.811516 6.4159 …Run Code Online (Sandbox Code Playgroud)