均匀分布随机数
函数名有两种写法
tf.random.uniform
tf.random_uniform
tf.random.uniform(
shape,
minval=0,
maxval=None,
dtype=tf.float32,
seed=None,
name=None
)
The generated values follow a uniform distribution in the range [minval, maxval). The lower bound minval is included in the range, while the upper bound maxval is excluded.
For floats, the default range is [0, 1). For ints, at least maxval must be specified explicitly.
生成均为分布的随机值,取值范围为[minval, maxval)
floats的默认取值范围为[0,1), ints需要指定最大值
random = random_ops.random_uniform(
noise_shape, seed=None, dtype=x.dtype)
# [0.23802626 0.12538171 0.36279774 0.9606353 0.28212202 0.52161884
# 0.15747523 0.42480624 0.8671547 0.77771187]
print(random.eval())