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面向对象编程基础解析(二)
Oct 26 Python
Python中is和==的区别详解
Nov 15 Python
使用python将mysql数据库的数据转换为json数据的方法
Jul 01 Python
Python类中方法getitem和getattr详解
Aug 30 Python
python英语单词测试小程序代码实例
Sep 09 Python
Django 框架模型操作入门教程
Nov 05 Python
基于Python的Jenkins的二次开发操作
May 12 Python
浅谈sklearn中predict与predict_proba区别
Jun 28 Python
解决Keras中循环使用K.ctc_decode内存不释放的问题
Jun 29 Python
Python制作一个仿QQ办公版的图形登录界面
Sep 22 Python
详解Java中一维、二维数组在内存中的结构
Feb 11 Python
python中%格式表达式实例用法
Jun 18 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
oracle资料库函式库
2006/10/09 PHP
thinkphp视图模型查询提示ERR: 1146:Table 'db.pr_order_view' doesn't exist的解决方法
2014/10/30 PHP
php获取四位字母和数字的随机数的实现方法
2015/01/09 PHP
tp5实现微信小程序多图片上传到服务器功能
2018/07/16 PHP
PHP实现断点续传乱序合并文件的方法
2018/09/06 PHP
Laravel框架集合用法实例浅析
2020/05/14 PHP
如何实现JS函数的重载
2006/09/22 Javascript
JavaScript 中的事件教程
2007/04/05 Javascript
JavaScript 乱码问题
2009/08/06 Javascript
javascript权威指南 学习笔记之变量作用域分享
2011/09/28 Javascript
轻松实现jquery手风琴效果
2016/01/14 Javascript
jQuery获取当前点击的对象元素(实现代码)
2016/05/19 Javascript
基于CSS3和jQuery实现跟随鼠标方位的Hover特效
2016/07/25 Javascript
完美解决jQuery 鼠标快速滑过后,会执行多次滑出的问题
2016/12/08 Javascript
JavaScript用构造函数如何获取变量的类型名
2016/12/23 Javascript
关于javascript作用域的常见面试题分享
2017/06/18 Javascript
解决ztree搜索中多级菜单展示不全问题
2017/07/05 Javascript
webpack构建react多页面应用详解
2017/09/15 Javascript
关于Angularjs中跨域设置白名单问题
2018/04/17 Javascript
Bootstrap-table使用footerFormatter做统计列功能
2018/09/07 Javascript
手淘flexible.js框架使用和源代码讲解小结
2018/10/15 Javascript
Vuex的基本概念、项目搭建以及入坑点
2018/11/04 Javascript
关于vue的npm run dev和npm run build的区别介绍
2019/01/14 Javascript
Vue.js项目实战之多语种网站的功能实现(租车)
2019/08/07 Javascript
基于jQuery实现可编辑的表格
2019/12/11 jQuery
python 获取字符串MD5值方法
2018/05/29 Python
使用python爬取微博数据打造一颗“心”
2019/06/28 Python
SVG实现多彩圆环倒计时效果的示例代码
2017/11/21 HTML / CSS
俄罗斯三星品牌商店:GalaxyStore
2020/11/04 全球购物
中软Java笔试题
2012/11/11 面试题
公司年底活动方案
2014/08/17 职场文书
酒店前台接待岗位职责
2015/04/02 职场文书
研讨会通知
2015/04/27 职场文书
遗嘱范文
2015/08/07 职场文书
Echarts如何重新渲染实例详解
2022/05/30 Javascript
JS实现九宫格拼图游戏
2022/06/28 Javascript