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实现统计代码行数的方法
May 22 Python
python subprocess 杀掉全部派生的子进程方法
Jan 16 Python
Python实现文件内容批量追加的方法示例
Aug 29 Python
tensorflow实现逻辑回归模型
Sep 08 Python
Python实现E-Mail收集插件实例教程
Feb 06 Python
python处理DICOM并计算三维模型体积
Feb 26 Python
使用python进行广告点击率的预测的实现
Jul 04 Python
django foreignkey(外键)的实现
Jul 29 Python
PyTorch中反卷积的用法详解
Dec 30 Python
详解python中各种文件打开模式
Jan 19 Python
基于selenium及python实现下拉选项定位select
Jul 22 Python
selenium+python自动化78-autoit参数化与批量上传功能的实现
Mar 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
PHP 字符串分割和比较
2009/10/06 PHP
php匹配字符中链接地址的方法
2014/12/22 PHP
Yii CDBCriteria常用方法实例小结
2017/01/19 PHP
如何通过View::first使用Laravel Blade的动态模板详解
2017/09/21 PHP
php和redis实现秒杀活动的流程
2019/07/17 PHP
php 利用socket发送GET,POST请求的实例代码
2020/07/04 PHP
基于jquery的自定义鼠标提示效果 jquery.toolTip
2010/11/14 Javascript
在网站上应该用的30个jQuery插件整理
2011/11/03 Javascript
浅谈Javascript事件模拟
2012/06/27 Javascript
ext combobox动态加载数据库数据(附前后台)
2014/06/17 Javascript
JS实现超简单的仿QQ折叠菜单效果
2015/09/21 Javascript
利用Js+Css实现折纸动态导航效果实例源码
2017/01/25 Javascript
vue keep-alive请求数据的方法示例
2018/05/16 Javascript
实例分析编写vue组件方法
2019/02/12 Javascript
微信小程序实现点击图片放大预览
2019/10/21 Javascript
javascript实现放大镜功能
2020/12/09 Javascript
Python实现方便使用的级联进度信息实例
2015/05/05 Python
Python常用小技巧总结
2015/06/01 Python
Python max内置函数详细介绍
2016/11/17 Python
spyder常用快捷键(分享)
2017/07/19 Python
基于python(urlparse)模板的使用方法总结
2017/10/13 Python
Python中摘要算法MD5,SHA1简介及应用实例代码
2018/01/09 Python
Python爬虫的两套解析方法和四种爬虫实现过程
2018/07/20 Python
Python双向循环链表实现方法分析
2018/07/30 Python
python利用多种方式来统计词频(单词个数)
2019/05/27 Python
选择python进行数据分析的理由和优势
2019/06/25 Python
Python动态强类型解释型语言原理解析
2020/03/25 Python
python 基于卡方值分箱算法的实现示例
2020/07/17 Python
通俗易懂了解Python装饰器原理
2020/09/17 Python
用python对excel查重
2020/12/07 Python
Python3中的tuple函数知识点讲解
2021/01/03 Python
英国DVD和蓝光碟片购买网站:Zoom.co.uk(电影和电视)
2019/09/23 全球购物
期终自我鉴定
2014/02/17 职场文书
财务会计自荐信范文
2014/02/21 职场文书
主管会计岗位职责
2014/03/13 职场文书
物业工程部经理岗位职责
2015/04/09 职场文书