tf.random_uniform的使用

来源:互联网 发布:java项目开发源代码 编辑:程序博客网 时间:2024/06/10 09:00

tf.random_uniform((4, 4), minval=low,maxval=high,dtype=tf.float32)))返回4*4的矩阵,产生于low和high之间,产生的值是均匀分布的。

例如:

[python] view plain copy
  1. import tensorflow as tf  
  2. import numpy as np  
  3.   
  4. with tf.Session() as sess:  
  5.     print(sess.run(tf.random_uniform(  
  6.         (44), minval=-0.5,  
  7.         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]]

原创粉丝点击