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 相关文章推荐
用Python创建声明性迷你语言的教程
Apr 13 Python
基于Python实现文件大小输出
Jan 11 Python
Python列表和元组的定义与使用操作示例
Jul 26 Python
Python实现Logger打印功能的方法详解
Sep 01 Python
python reduce 函数使用详解
Dec 05 Python
Python Tkinter实现简易计算器功能
Jan 30 Python
使用Python进行目录的对比方法
Nov 01 Python
python中设置超时跳过,超时退出的方式
Dec 13 Python
python 爬取疫情数据的源码
Feb 09 Python
使用Python判断一个文件是否被占用的方法教程
Dec 16 Python
一文带你掌握Pyecharts地理数据可视化的方法
Feb 06 Python
Pillow图像处理库安装及使用
Apr 12 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
把从SQL中取出的数据转化成XMl格式
2006/10/09 PHP
php实现文件下载更能介绍
2012/11/23 PHP
php使用base64加密解密图片示例分享
2014/01/20 PHP
php获取远程文件的内容和大小
2015/11/03 PHP
php短信接口代码
2016/05/13 PHP
php版微信公众号接口实现发红包的方法
2016/10/14 PHP
完美解决php 导出excle的.csv格式的数据时乱码问题
2017/02/18 PHP
[原创]php使用strpos判断字符串中数字类型子字符串出错的解决方法
2017/04/01 PHP
PHP数组Key强制类型转换实现原理解析
2020/09/01 PHP
再谈IE中Flash控件的自动激活 ObjectWrap
2007/03/09 Javascript
网页上的Javascript编辑器和代码格式化
2010/04/25 Javascript
JQUERY设置IFRAME的SRC值的代码
2010/11/30 Javascript
jQuery获取样式中的背景颜色属性值/颜色值
2012/12/17 Javascript
Javascript浅谈之引用类型
2013/12/18 Javascript
js中浮点型运算BUG的解决方法说明
2014/01/06 Javascript
jQuery动态加载css文件实现方法
2016/06/15 Javascript
详解jquery validate实现表单验证 (正则表达式)
2017/01/18 Javascript
vue-dialog的弹出层组件
2020/05/25 Javascript
JavaScript表格隔行变色和Tab标签页特效示例【附jQuery版】
2019/07/11 jQuery
vue项目中锚点定位替代方式
2019/11/13 Javascript
Node.js 在本地生成日志文件的方法
2020/02/07 Javascript
[02:27]《DAC最前线》之附加赛征程
2015/01/29 DOTA
[00:49]完美世界DOTA2联赛10月28日开团时刻:随便打
2020/10/29 DOTA
Python实现3行代码解简单的一元一次方程
2014/08/18 Python
Python面向对象之接口、抽象类与多态详解
2018/08/27 Python
Python实现将字符串的首字母变为大写,其余都变为小写的方法
2019/06/11 Python
在Pandas中处理NaN值的方法
2019/06/25 Python
css3 background属性调整增强介绍
2010/12/18 HTML / CSS
AmazeUI 网格的实现示例
2020/08/13 HTML / CSS
舒适的豪华鞋:Taryn Rose
2018/05/03 全球购物
本科毕业生求职自荐信
2014/04/09 职场文书
校园环保建议书
2014/05/14 职场文书
2014年学校体育工作总结
2014/12/08 职场文书
处罚决定书范文
2015/06/24 职场文书
组织委员竞选稿
2015/11/21 职场文书
创业计划书之密室逃脱
2019/11/08 职场文书