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获得文件创建时间和修改时间的方法
Jun 30 Python
python+pyqt5实现图片批量缩放工具
Mar 18 Python
python之mock模块基本使用方法详解
Jun 27 Python
Python程序打包工具py2exe和PyInstaller详解
Jun 28 Python
python的几种矩阵相乘的公式详解
Jul 10 Python
python输出决策树图形的例子
Aug 09 Python
简单了解python中的与或非运算
Sep 18 Python
windows中安装Python3.8.0的实现方法
Nov 19 Python
python扫描线填充算法详解
Feb 19 Python
python解包用法详解
Feb 17 Python
Python中for后接else的语法使用
May 18 Python
python使用PySimpleGUI设置进度条及控件使用
Jun 10 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
傻瓜化配置PHP环境――Appserv
2006/12/13 PHP
PHP动态编译出现Cannot find autoconf的解决方法
2014/11/05 PHP
PHP实现链式操作的三种方法详解
2017/11/16 PHP
php字符串截取函数mb_substr用法实例分析
2019/06/25 PHP
XAMPP升级PHP版本实现步骤解析
2020/09/04 PHP
ajax异步刷新实现更新数据库
2012/12/03 Javascript
Flexigrid在IE下不显示数据的处理的解决方法
2013/10/24 Javascript
JS对象转换为Jquery对象实现代码
2013/12/29 Javascript
在Firefox下js select标签点击无法弹出
2014/03/06 Javascript
TypeScript Type Innference(类型判断)
2016/03/10 Javascript
Bootstrap组件(一)之菜单
2016/05/11 Javascript
浅析angularJS中的ui-router和ng-grid模块
2016/05/20 Javascript
jQuery基于ID调用指定iframe页面内的方法
2016/07/06 Javascript
基于jquery实现的鼠标悬停提示案例
2016/12/11 Javascript
AngularJS实现使用路由切换视图的方法
2017/01/24 Javascript
jquery中封装函数传递当前元素的方法示例
2017/05/05 jQuery
web.js.字符串与正则表达式操作
2017/05/13 Javascript
Vue.js弹出模态框组件开发的示例代码
2017/07/26 Javascript
layer.js之回调销毁对话框的例子
2019/09/11 Javascript
Vue 图片压缩并上传至服务器功能
2020/01/15 Javascript
JavaScript实现动态留言板
2020/03/16 Javascript
python中append实例用法总结
2019/07/30 Python
Python如何优雅删除字符列表空字符及None元素
2020/06/25 Python
Python如何使用ElementTree解析xml
2020/10/12 Python
详解如何通过H5(浏览器/WebView/其他)唤起本地app
2017/12/11 HTML / CSS
html5关于外链嵌入页面通信问题(postMessage解决跨域通信)
2020/07/20 HTML / CSS
Servlet面试题库
2015/07/18 面试题
人力资源专业推荐信
2013/11/29 职场文书
好邻里事迹材料
2014/01/16 职场文书
公务员中国梦演讲稿
2014/08/19 职场文书
党的群众路线教育实践活动专题组织生活会发言材料
2014/10/17 职场文书
如何书写授权委托书?
2019/06/25 职场文书
详解RedisTemplate下Redis分布式锁引发的系列问题
2021/04/27 Redis
Java基于字符界面的简易收银台
2021/06/26 Java/Android
elementui的el-popover修改样式不生效的解决
2021/06/30 Javascript
MYSQL优化之数据表碎片整理详解
2022/04/03 MySQL