[TensorFlow] demo1 tf.random_uniform 函数
来源:互联网 发布:lol防封源码 编辑:程序博客网 时间:2024/06/06 19:24
tensorflow/tensorflow/python/ops的 random_ops.py 文件有定义
# pylint: disable=protected-accessdef random_normal(shape, mean=0.0, stddev=1.0, dtype=dtypes.float32, seed=None, name=None): """Outputs random values from a normal distribution. Args: shape: A 1-D integer Tensor or Python array. The shape of the output tensor. mean: A 0-D Tensor or Python value of type `dtype`. The mean of the normal distribution. stddev: A 0-D Tensor or Python value of type `dtype`. The standard deviation of the normal distribution. dtype: The type of the output. seed: A Python integer. Used to create a random seed for the distribution. See @{tf.set_random_seed} for behavior. name: A name for the operation (optional). Returns: A tensor of the specified shape filled with random normal values. """ with ops.name_scope(name, "random_normal", [shape, mean, stddev]) as name: shape_tensor = _ShapeTensor(shape) mean_tensor = ops.convert_to_tensor(mean, dtype=dtype, name="mean") stddev_tensor = ops.convert_to_tensor(stddev, dtype=dtype, name="stddev") seed1, seed2 = random_seed.get_seed(seed) rnd = gen_random_ops._random_standard_normal( shape_tensor, dtype, seed=seed1, seed2=seed2) mul = rnd * stddev_tensor value = math_ops.add(mul, mean_tensor, name=name) return value
可以看出,api r1.3(官网)和api r1.4(github)上的说明是有不同的。函数名一样,但是我们需要知道传入的参数的不同。
在api r1.3中
random_uniform(
shape,
minval=0,
maxval=None,
dtype=tf.float32,
seed=None,
name=None
)
参数:
shape:一维整数张量或Python数组。 输出张量的形状。
minval:dtype类型的0-D张量或Python值。 生成的随机值范围的下限。 默认为0。
maxval:类型为dtype的0-D张量或Python值。 要生成的随机值范围的上限。 如果dtype是浮点,则默认为1。
dtype:输出的类型:“float16,float32,float64,int32或orint64”。
seed:一个Python整数。 用于为分发创建一个随机种子。 有关行为,请参阅tf.set_random_seed。
name:操作的名称(可选)。
============================================
在api1.4中
参数:
def random_normal(shape,
mean=0.0,
stddev=1.0,
dtype=dtypes.float32,
seed=None,
name=None):
shape: A 1-D integer Tensor or Python array. The shape of the output tensor.
mean: A 0-D Tensor or Python value of type `dtype`. The mean of the normal
distribution.
stddev: A 0-D Tensor or Python value of type `dtype`. The standard deviation
of the normal distribution.
dtype: The type of the output.
seed: A Python integer. Used to create a random seed for the distribution.
See
@{tf.set_random_seed}
for behavior.
name: A name for the operation (optional).
- [TensorFlow] demo1 tf.random_uniform 函数
- [TensorFlow] demo1 tf.zeros 函数
- [TensorFlow] demo1 tf.square 函数
- [TensorFlow] demo1 tf.initialize_all_variables函数换成新的tf.global_variables_initializer函数
- tensorflow生成随机数的操作 tf.random_normal & tf.random_uniform & tf.truncated_normal & tf.random_shuffle
- tf.random_uniform的使用
- tf.random_uniform的使用
- tf.random_uniform的使用
- 【Tensorflow】tf.placeholder函数
- 【Tensorflow】tf.reshape 函数
- 【Tensorflow】tf.argmax函数
- Tensorflow tf.placeholder函数
- 【Tensorflow】tf.Graph()函数
- 【Tensorflow】tf.placeholder函数
- 【Tensorflow】tf.concat函数
- TensorFlow-tf.nn.conv2d 函数
- 【Tensorflow】tf.nn.relu函数
- 【Tensorflow】tf.nn.dropout函数
- hadoop-3.0.0集群环境搭建、配置
- java学习初探十八之线程和进程的区别
- 关于怎么解决opencv无法显示图片的解决办法
- python爬虫 scrapy框架学习
- openstack中region az aggregate概念介绍
- [TensorFlow] demo1 tf.random_uniform 函数
- set方法总结
- JSON解析-python实现
- 巨简单的轮播图
- MongoDB的索引
- 我,一个菜鸟的第一篇博客
- 二维码扫描
- python——后起之秀
- vue引入JQ的方法