tf.random_uniform((4, 4), minval=low,maxval=high,dtype=tf.float32)))返回4*4的矩阵,产生于low和high之间,产生的值是均匀分布的。
例如:
import tensorflow as tf import numpy as np with tf.Session() as sess:
print(sess.run(tf.random_uniform(
(, ), minval=-0.5,
maxval=0.5,dtype=tf.float32)))
输出:
[[ 0.23706067 0.42579055 0.16444612 0.12134457]
[ 0.14245582 0.32224071 -0.3107301 0.29911542]
[-0.03472292 -0.37411058 -0.22680879 0.21656895]
[-0.37798405 0.31725729 -0.17690742 -0.02995324]]