tf.truncated_normal(shape, mean, stddev) :shape表示生成张量的维度,mean是均值,stddev是标准差。这个函数产生正太分布,均值和标准差自己设定。这是一个截断的产生正太分布的函数,就是说产生正太分布的值如果与均值的差值大于两倍的标准差,那就重新生成。和一般的正太分布的产生随机数据比起来,这个函数产生的随机数与均值的差距不会超过两倍的标准差,但是一般的别的函数是可能的。

例如:

import tensorflow as tf;
import numpy as np;
import matplotlib.pyplot as plt; c = tf.truncated_normal(shape=[10,10], mean=0, stddev=1) with tf.Session() as sess:
print sess.run(c)
 

输出:

[[ 1.95758033 -0.68666345 -1.83860338  0.78213859 -1.08119416 -1.44530308
   0.38035342  0.57904619 -0.57145643 -1.22899497]
 [-0.75853795  0.48202974  1.03464043  1.19210851 -0.15739718  0.8506189
   1.18259966 -0.99061841 -0.51968449  1.38996458]
 [ 1.05636907 -0.02668529  0.64182931  0.4110294  -0.4978295  -0.64912242
   1.27779591 -0.01533993  0.47417602 -1.28639436]
 [-1.65927458 -0.364887   -0.45535028  0.078814   -0.30295736  1.91779387
  -0.66928798 -0.14847915  0.91875714  0.61889237]
 [-0.01308221 -0.38468206  1.34700036  0.64531708  1.15899456  1.09932268
   1.22457981 -1.1610316   0.59036094 -1.97302651]
 [-0.24886213  0.82857937  0.09046989  0.39251322  0.21155456 -0.27749416
   0.18883201  0.08812679 -0.32917103  0.20547724]
 [ 0.05388507  0.45474565  0.23398806  1.32670367 -0.01957406  0.52013856
  -1.13907862 -1.71957874  0.75772947 -1.01719368]
 [ 0.27155915  0.05900437  0.81448066 -0.37997526 -0.62020499 -0.88820189
   1.53407145 -0.01600445 -0.4236775  -1.68852305]
 [ 0.78942037 -1.32458341 -0.91667277 -0.00963761  0.76824385 -0.5405798
  -0.73307443 -1.19854116 -0.66179073  0.26329204]
 [ 0.59473759 -0.37507254 -1.21623695 -1.30528259  1.18013096 -1.32077384
  -0.59241474 -0.28063133  0.12341146  0.48480138]]

tf.truncated_normal的用法的更多相关文章

  1. TensorFlow tf.app&tf.app.flags用法介绍

    TensorFlow tf.app&tf.app.flags用法介绍 TensorFlow tf.app argparse  tf.app.flags 下面介绍 tf.app.flags.FL ...

  2. TensorFlow函数:tf.truncated_normal

    tf.truncated_normal函数 tf.truncated_normal( shape, mean=0.0, stddev=1.0, dtype=tf.float32, seed=None, ...

  3. 深度学习原理与框架-Tensorflow卷积神经网络-卷积神经网络mnist分类 1.tf.nn.conv2d(卷积操作) 2.tf.nn.max_pool(最大池化操作) 3.tf.nn.dropout(执行dropout操作) 4.tf.nn.softmax_cross_entropy_with_logits(交叉熵损失) 5.tf.truncated_normal(两个标准差内的正态分布)

    1. tf.nn.conv2d(x, w, strides=[1, 1, 1, 1], padding='SAME')  # 对数据进行卷积操作 参数说明:x表示输入数据,w表示卷积核, stride ...

  4. tf.concat, tf.stack和tf.unstack的用法

    tf.concat, tf.stack和tf.unstack的用法 tf.concat相当于numpy中的np.concatenate函数,用于将两个张量在某一个维度(axis)合并起来,例如: a ...

  5. tf.truncated_normal

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

  6. tensorflow 生成随机数 tf.random_normal 和 tf.random_uniform 和 tf.truncated_normal 和 tf.random_shuffle

    ____tz_zs tf.random_normal 从正态分布中输出随机值. . <span style="font-size:16px;">random_norma ...

  7. tensorflow生成随机数的操作 tf.random_normal & tf.random_uniform & tf.truncated_normal & tf.random_shuffle

    tf.random_normal 从正态分布输出随机值. random_normal(shape,mean=0.0,stddev=1.0,dtype=tf.float32,seed=None,name ...

  8. tf.truncated_normal和tf.random_normal使用方法的区别

    1.tf.truncated_normal使用方法 tf.truncated_normal(shape, mean=0.0, stddev=1.0, dtype=tf.float32, seed=No ...

  9. 【转载】 TensorFlow tf.app&tf.app.flags用法介绍

    作 者:marsggbo 出 处:https://www.cnblogs.com/marsggbo版权声明:署名 - 非商业性使用 - 禁止演绎,协议普通文本 | 协议法律文本. ---------- ...

随机推荐

  1. Fata7y Ya Warda! SPOJ - DRUIDEOI 单调栈

    题意:1e5个数围成一个环.现在要输出每个数左右第一个大于它的数的下标.若没有,则输出-1. 题解:单调栈板题.只是要把数据压入栈压两遍来模仿环.    具体分析:考虑一个递减的数列.要找左边最大的 ...

  2. MySQL权限和用户管理

    Mysql权限系统(由mysql权限表进行控制user和db)通过下面两个方面进行认证: 1)对于连接的用户进行身份验证,合法的通过验证,不合法的拒绝连接. 2)对于通过连接认证的用户,可以在合法的范 ...

  3. iOS-多语言版本开发(二)(转载)

    题记   iOS 多语言版本的开发(一) 中我们完成了让应用跟随系统语言进行切换,而用户自己却不能切换的功能,也基本上算是实现了多语言版本:可是,对于某些应用来说,实现跟随系统语言切换的同时, 也想要 ...

  4. 修改机器名、IP对arcgis server、portal的影响?

    修改机器名.IP是否对ArcGIS Server .Portal等有影响? 请教赛姐:修改IP对ArcGIS Server .Portal 无影响,不过建议将ArcGIS Server .Portal ...

  5. /etc/rc.d/rc.local 自定义开机启动程序

    /etc/rc.d/rc.local 用于用户自定义开机启动程序,可以往里写开机要执行的命令或脚本,线上的配置如下: [root@localhost ~]$ cat /etc/rc.d/rc.loca ...

  6. JavaScript中通过arguments对象实现对象的重载

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  7. CSS 3列等高

    方法1: <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"&g ...

  8. java-JProfiler(五)-监控性能

    原文地址:http://blog.csdn.net/chendc201/article/details/22897999 一.基础认识 1. 在Live Memory视图里右击相关类,选中Mark C ...

  9. ubuntu 安装ftp,配置,和java调用

    1:安装 ftp服务器 sudo apt-get install vsftpd 自动安装使用的是主机的用户名和密码:liyafei,1367xxx 访问方式,ftp://localhost:21,ft ...

  10. Ghost硬盘对拷

    Ghost硬盘对拷 优点:全盘完全100%对拷,包括原有操作系统也可使用.新硬盘对拷结束后,可直接插上电脑使用.消耗时间最短. 困难:对于第一次操作Ghost对拷的新人来说,需要严格对照图片步骤教程. ...