1、输出服从正太分布
random_normal(shape, mean=0.0, stddev=1.0, dtype=tf.float32)
shape:一个一维整数张量或Python数组。代表张量的形状。
mean:数据类型为dtype的张量值或Python值。是正态分布的均值。
stddev:数据类型为dtype的张量值或Python值。是正态分布的标准差。
举例:
import tensorflow as tf
w1 = tf.Variable(tf.random_normal([2, 3], stddev=1, seed=1))
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
print (w1)
print (sess.run(w1))
输出:
<tf.Variable 'Variable:0' shape=(2, 3) dtype=float32_ref>
[[-0.8113182 1.4845988 0.06532937]
[-2.4427042 0.0992484 0.5912243 ]]
Process finished with exit code 0
2、均匀分布[min,max)
random_uniform(shape, minval=0, maxval=None, dtype=dtypes.float32)
import tensorflow as tf
with tf.Session() as sess:
data = tf.rando