话谈tensorflow常见函数truncated_normal与random_normal 联系区别

版权声明:博客为作者平时学习备忘,参考资料已在文尾列出一并表示感谢。如若转载,请列明出处。 https://blog.csdn.net/woai8339/article/details/84668482

tf.truncated_normalrandom_normal都可以生成符合正态分布的数据,对于前者,对于生成超过标准差2倍的数据会丢弃,后者就按指定标准差生成数据就好。
for example:

>>> c = tf.truncated_normal(shape=[2, 2], mean=0, stddev=1)
>>> with tf.Session() as sess:
...     sess.run(c)
...
array([[ 0.5009586 ,  0.48813978],
       [ 1.2601391 , -1.9418849 ]], dtype=float32)
>>> c = tf.random_normal(shape=[2, 2], mean=0, stddev=1)
>>> with tf.Session() as sess:
...     sess.run(c)
...
array([[ 0.36184996, -0.33625147],
       [ 0.32761842,  1.0771633 ]], dtype=float32)

Ref:
1、https://blog.csdn.net/u014687582/article/details/78027061
2、https://blog.csdn.net/ywx1832990/article/details/78479780
3、http://www.tensorfly.cn/tfdoc/api_docs/python/state_ops.html
4、https://hackaday.com/2017/04/11/introduction-to-tensorflow/
5、https://stackoverflow.com/questions/41704484/what-is-difference-between-tf-truncated-normal-and-tf-random-normal/41704789

猜你喜欢

转载自blog.csdn.net/woai8339/article/details/84668482