TensorFlow的tf.random_uniform()函数的用法

tf.random_uniform((6, 6), minval=low,maxval=high,dtype=tf.float32)))

返回6*6的矩阵,产生于low和high之间,产生的值是均匀分布的。

 
  1. import tensorflow as tf

  2. with tf.Session() as sess:

  3. print(sess.run(tf.random_uniform(

  4. (6,6), minval=-0.5,

  5. maxval=0.5, dtype=tf.float32)))

 
  1. [[ 0.47818196 -0.0463798 -0.48545432 0.48667777 0.1448754 0.31394303]

  2. [ 0.07446766 0.37638378 0.3001852 -0.1716789 0.03881919 0.14070213]

  3. [ 0.14747012 -0.14895666 -0.35274172 -0.19400203 -0.26068127 0.10212302]

  4. [ 0.29586768 0.16780066 -0.34365273 -0.3228333 0.42329776 0.35237122]

  5. [-0.34602797 -0.46733367 0.46615827 -0.20312655 -0.37987483 0.41316974]

  6. [ 0.39296162 0.32745218 -0.32554448 -0.14309132 -0.16133463 0.40627968]]

https://blog.csdn.net/sunshunli/article/details/80186884?utm_source=copy

猜你喜欢

转载自blog.csdn.net/qq_37701443/article/details/82845499