tf.truncated_normal()

参考官方说明文档

format: truncated_normal(shape, mean=0.0, stddev=1.0, dtype=tf.float32, seed=None, name=None)

Argus:

shape: A 1-D integer Tensor or Python array. The shape of the output tensor.(一维的整形Tensor或者python 。其实也就是python的list。指的是输出tensor的shape)

mean: A 0-D Tensor or Python value of type `dtype`. The mean of thetruncated normal distribution.(均值:数据类型为参数‘dtype’的0维的Tensor,也就单个数值的tensor或      者数据类型为参数‘dtype’的python值)The mean of the truncated normal distribution.(这个是截断正态分布的均值)

stddev: A 0-D Tensor or Python value of type `dtype`. The standard deviation(数据类型为参数‘dtype’的0维的Tensor或者python值,也就是单个数值,这个是标准差)

dtype: The type of the output(输出的数据类型,注意这个数据类型有默认值,而且这个数据类型也规定了shape,mean,stddev的数据类型)

seed: A Python integer. Used to create a random seed for the distribution.(python整数,用来为分布产生一个随机种子,很少用到)

name: A name for the operation (optional)

Returns: A tensor of the specified shape filled with random truncated normal values.(返回一个指定shape的tensor)

  这是一个截断的产生正太分布的函数,就是说产生正太分布的值如果与均值的差值大于两倍的标准差,那就重新生成。和一般的正太分布的产生随机数据比起来,这个函数产生的随机数与均值的差距不会超过两倍的标准差,但是一般的别的函数是可能的。

栗子

import tensorflow as tf
result=tf.truncated_normal(shape=[5,5],mean=0,stddev=1)
with tf.Session() as sess:
    print(sess.run(result))



评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值