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实现备份文件实例
Sep 16 Python
python实现将pvr格式转换成pvr.ccz的方法
Apr 28 Python
Python的爬虫程序编写框架Scrapy入门学习教程
Jul 02 Python
Python实现将文本生成二维码的方法示例
Jul 18 Python
vue.js实现输入框输入值内容实时响应变化示例
Jul 07 Python
python numpy 按行归一化的实例
Jan 21 Python
python实现桌面壁纸切换功能
Jan 21 Python
python小程序实现刷票功能详解
Jul 17 Python
Python 继承,重写,super()调用父类方法操作示例
Sep 29 Python
python中使用input()函数获取用户输入值方式
May 03 Python
什么是Python中的顺序表
Jun 02 Python
如何在Win10系统使用Python3连接Hive
Oct 15 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初学者们头痛的十四个问题
2007/01/15 PHP
PHP连接MySQL的2种方法小结以及防止乱码
2014/03/11 PHP
php保存任意网络图片到服务器的方法
2015/04/14 PHP
php代码架构的八点注意事项
2016/01/25 PHP
php 可变函数使用小结
2018/06/12 PHP
PHP 面向对象程序设计之类属性与类常量实现方法分析
2020/04/13 PHP
JS Excel读取和写入操作(模板操作)实现代码
2010/04/11 Javascript
jQuery实现锚点scoll效果实例分析
2015/03/10 Javascript
jQuery左右滚动支持图片放大缩略图图片轮播代码分享
2015/08/26 Javascript
JavaScript浏览器对象模型BOM(BrowserObjectModel)实例详解
2016/11/29 Javascript
BootStrap Tooltip插件源码解析
2016/12/27 Javascript
Canvas + JavaScript 制作图片粒子效果
2017/02/08 Javascript
JavaScript之排序函数_动力节点Java学院整理
2017/06/30 Javascript
JS中使用gulp实现压缩文件及浏览器热加载功能
2017/07/12 Javascript
nodejs中解决异步嵌套循环和循环嵌套异步的问题
2017/07/12 NodeJs
原生JS检测CSS3动画是否结束的方法详解
2019/01/27 Javascript
JS实现简单tab选项卡切换
2019/10/25 Javascript
jQuery 图片查看器插件 Viewer.js用法简单示例
2020/04/04 jQuery
jQuery列表动态增加和删除的实现方法
2020/11/05 jQuery
python生成日历实例解析
2014/08/21 Python
Django 中使用流响应处理视频的方法
2018/07/20 Python
Python在图片中插入大量文字并且自动换行
2019/01/02 Python
Python3显示当前时间、计算时间差及时间加减法示例代码
2019/09/07 Python
python爬虫学习笔记之Beautifulsoup模块用法详解
2020/04/09 Python
Django 解决上传文件时,request.FILES为空的问题
2020/05/20 Python
Python实现曲线拟合的最小二乘法
2021/02/19 Python
标签和贴纸印刷:Lightning Labels
2018/03/22 全球购物
优秀员工年终发言演讲稿
2014/01/01 职场文书
中学教师管理制度
2014/01/14 职场文书
群众路线批评与自我批评
2014/02/06 职场文书
陈欧广告词
2014/03/14 职场文书
处级干部反四风个人对照检查材料思想汇报
2014/09/27 职场文书
2016新年问候语大全
2015/11/11 职场文书
预备党员入党思想汇报(范文)
2019/08/14 职场文书
CSS3 天气图标动画效果
2021/04/06 HTML / CSS
Django利用AJAX技术实现博文实时搜索
2021/05/06 Python