参考官方说明文档
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))