用于产生随机数。
tf.random_uniform((6, 6), minval=low,maxval=high,dtype=tf.float32)))返回6*6的矩阵,产生于low和high之间,产生的值是均匀分布的。
import tensorflow as tf
with tf.Session() as sess:
print(sess.run(tf.random_uniform((6,6), minval=-0.5,maxval=0.5, dtype=tf.float32)))
Output:
----------------------------------------------------------------------------
[[ 0.07299805 0.476058 0.18166184 -0.31572092 0.22426641 -0.14638352]
[-0.02340996 0.46468496 -0.02383947 0.46722507 -0.08757818 -0.11083972]
[ 0.07638371 0.23738658 0.44821632 0.23477304 -0.19132912 0.3916086 ]
[-0.49850106 -0.2187239 0.08246636 -0.34344006 -0.17894387 0.16244876]
[ 0.4683708 -0.38189948 0.4437915 0.3144766 0.30762875 -0.08816886]
[-0.29303634 -0.16211808 0.4511906 0.29041123 -0.30339313 -0.40015614]]
----------------------------------------------------------------------------