1. 文章
  2. 文章详情

TensorFlow 框架 tf.random_uniform() 随机值函数的用法

random_uniform函数定义

def random_uniform(shape,
minval=0,
maxval=None,
dtype=dtypes.float32,
seed=None,
name=None):

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=1,
maxval=2, dtype=tf.float32)))

输出

[[1.0083613 1.901522 1.7820673 1.8347588 1.389759 1.1309354]
[1.3078389 1.3999566 1.5391288 1.190904 1.423022 1.056547 ]
[1.3372515 1.9718001 1.9459997 1.7823787 1.6229967 1.1110408]
[1.5895345 1.3306066 1.1292795 1.370655 1.5162055 1.735533 ]
[1.4266956 1.9627593 1.5428348 1.0182468 1.914475 1.5070438]
[1.9716156 1.2748424 1.6767707 1.3537116 1.8638859 1.1396391]]

发表评论

登录后才能评论

评论列表(0条)