TensorFlow中权重的随机初始化的方法


Posted in Python onFebruary 11, 2018

一开始没看懂stddev是什么参数,找了一下,在tensorflow/python/ops里有random_ops,其中是这么写的:

def random_normal(shape, mean=0.0, stddev=1.0, dtype=types.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
   [`set_random_seed`](../../api_docs/python/constant_op.md#set_random_seed)
   for behavior.
  name: A name for the operation (optional).

 Returns:
  A tensor of the specified shape filled with random normal values.
 """

也就是按照正态分布初始化权重,mean是正态分布的平均值,stddev是正态分布的标准差(standard deviation),seed是作为分布的random seed(随机种子,我百度了一下,跟什么伪随机数发生器还有关,就是产生随机数的),在mnist/concolutional中seed赋值为66478,挺有意思,不知道是什么原理。

后面还有truncated_normal的定义:

def truncated_normal(shape, mean=0.0, stddev=1.0, dtype=types.float32,
           seed=None, name=None):
 """Outputs random values from a truncated normal distribution.

 The generated values follow a normal distribution with specified mean and
 standard deviation, except that values whose magnitude is more than 2 standard
 deviations from the mean are dropped and re-picked.

 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
   truncated normal distribution.
  stddev: A 0-D Tensor or Python value of type `dtype`. The standard deviation
   of the truncated normal distribution.
  dtype: The type of the output.
  seed: A Python integer. Used to create a random seed for the distribution.
   See
   [`set_random_seed`](../../api_docs/python/constant_op.md#set_random_seed)
   for behavior.
  name: A name for the operation (optional).

 Returns:
  A tensor of the specified shape filled with random truncated normal values.
 """

截断正态分布,以前都没听说过。

TensorFlow还提供了平均分布等。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持三水点靠木。

Python 相关文章推荐
python3大文件解压和基本操作
Dec 15 Python
Python3.6.0+opencv3.3.0人脸检测示例
May 25 Python
Python实现通过继承覆盖方法示例
Jul 02 Python
python 自动批量打开网页的示例
Feb 21 Python
python3爬虫学习之数据存储txt的案例详解
Apr 24 Python
python+openCV调用摄像头拍摄和处理图片的实现
Aug 06 Python
PyCharm2020最新激活码+激活码补丁(亲测最新版PyCharm2020.2激活成功)
Nov 25 Python
python利用tkinter实现图片格式转换的示例
Sep 28 Python
python Selenium 库的使用技巧
Oct 16 Python
如何用python爬取微博热搜数据并保存
Feb 20 Python
Python序列化与反序列化相关知识总结
Jun 08 Python
python3实现常见的排序算法(示例代码)
Jul 04 Python
python的staticmethod与classmethod实现实例代码
Feb 11 #Python
Python语言的变量认识及操作方法
Feb 11 #Python
利用Opencv中Houghline方法实现直线检测
Feb 11 #Python
tensorflow输出权重值和偏差的方法
Feb 10 #Python
详解tensorflow实现迁移学习实例
Feb 10 #Python
Python学习之Django的管理界面代码示例
Feb 10 #Python
Tensorflow 自带可视化Tensorboard使用方法(附项目代码)
Feb 10 #Python
You might like
三国漫画《火凤燎原》宣布动画化PV放出 预计2020年播出
2020/03/08 国漫
discuz authcode 经典php加密解密函数解析
2020/07/12 PHP
利用PHP函数计算中英文字符串长度的方法
2014/11/11 PHP
映彩衣的js随笔(js图片切换效果)
2011/07/31 Javascript
jquery实现输入框动态增减的实例代码
2013/07/14 Javascript
js 获取时间间隔实现代码
2014/05/12 Javascript
使用Javascript简单实现图片无缝滚动
2014/12/05 Javascript
删除javascript所创建子节点的方法
2015/05/21 Javascript
jquery实现美观的导航菜单鼠标提示特效代码
2015/09/06 Javascript
基于Vue单文件组件详解
2017/09/15 Javascript
EasyUI创建人员树的实例代码
2017/09/15 Javascript
Vue实现PopupWindow组件详解
2018/04/28 Javascript
webstorm中配置nodejs环境及npm的实例
2018/05/15 NodeJs
移动端如何用下拉刷新的方式实现上拉加载
2018/12/10 Javascript
详解React中合并单元格的正确写法
2019/01/08 Javascript
jQuery实现为table表格动态添加或删除tr功能示例
2019/02/19 jQuery
[01:08:29]DOTA2-DPC中国联赛定级赛 RNG vs Aster BO3第一场 1月9日
2021/03/11 DOTA
python 容器总结整理
2017/04/04 Python
Python使用matplotlib绘制正弦和余弦曲线的方法示例
2018/01/06 Python
Python序列循环移位的3种方法推荐
2018/04/09 Python
python 对dataframe下面的值进行大规模赋值方法
2018/06/09 Python
Python玩转PDF的各种骚操作
2019/05/06 Python
Python实现计算对象的内存大小示例
2019/07/10 Python
pytorch加载自己的图像数据集实例
2020/07/07 Python
python pip如何手动安装二进制包
2020/09/30 Python
CSS中几个与换行有关的属性简明总结
2014/04/15 HTML / CSS
临床医师专业个人自我评价范文
2013/11/07 职场文书
资料员的岗位职责
2013/11/20 职场文书
毕业生大学生活自我总结
2014/01/31 职场文书
市场营销专业毕业生求职信
2014/07/21 职场文书
高速铁道技术专业求职信
2014/08/09 职场文书
研究生导师推荐信
2014/09/06 职场文书
出国签证在职证明
2014/09/20 职场文书
2015感人爱情寄语
2015/02/26 职场文书
MySQL如何使用使用Xtrabackup进行备份和恢复
2021/06/21 MySQL
mongodb的安装和开机自启动详细讲解
2021/08/02 MongoDB