Tensorflow:tf.random_uniform()函数的用法

原文链接:https://blog.csdn.net/sunshunli/article/details/80186884

tf.random_uniform([rows, colomns], maxval = high, minval = low, dtype = tf.float32)
#返回一个维度为[rows, colomns],范围为[low, high]的均匀分布随机浮点数张量

例子:

import tensorflow as tf
with tf.Session() as sess:
    print(sess.run(tf.random_uniform(
        (6,6), minval=-0.5,
        maxval=0.5, dtype=tf.float32)))
[[ 0.47818196 -0.0463798  -0.48545432  0.48667777  0.1448754   0.31394303]
 [ 0.07446766  0.37638378  0.3001852  -0.1716789   0.03881919  0.14070213]
 [ 0.14747012 -0.14895666 -0.35274172 -0.19400203 -0.26068127  0.10212302]
 [ 0.29586768  0.16780066 -0.34365273 -0.3228333   0.42329776  0.35237122]
 [-0.34602797 -0.46733367  0.46615827 -0.20312655 -0.37987483  0.41316974]
 [ 0.39296162  0.32745218 -0.32554448 -0.14309132 -0.16133463  0.40627968]]

你可能感兴趣的:(Tensorflow:tf.random_uniform()函数的用法)