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网络编程学习笔记(三):socket网络服务器
Jun 09 Python
python自定义类并使用的方法
May 07 Python
Python操作MySQL数据库的三种方法总结
Jan 30 Python
PyQt5每天必学之工具提示功能
Apr 19 Python
win7 x64系统中安装Scrapy的方法
Nov 18 Python
Pycharm+Scrapy安装并且初始化项目的方法
Jan 15 Python
详解如何设置Python环境变量?
May 13 Python
python中pytest收集用例规则与运行指定用例详解
Jun 27 Python
python Tensor和Array对比分析
Jan 08 Python
pandas数据处理之绘图的实现
Jun 15 Python
Python2.x与3​​.x版本有哪些区别
Jul 09 Python
idea2020手动安装python插件的实现方法
Jul 17 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
1982年日本摄影师镜头下的中国孩子 那无忧无虑的童年
2020/03/12 杂记
yii中widget的用法
2014/12/03 PHP
PHP自定义多进制的方法
2016/11/03 PHP
PHP编程获取图片的主色调的方法【基于Imagick扩展】
2017/08/02 PHP
Yii2 中实现单点登录的方法
2018/03/09 PHP
thinkphp5 模型实例化获得数据对象的教程
2019/10/18 PHP
能说明你的Javascript技术很烂的五个原因分析
2011/10/28 Javascript
jquery获取及设置outerhtml的方法
2015/03/09 Javascript
使用vue.js开发时一些注意事项
2016/04/27 Javascript
jQuery弹出div层过2秒自动消失
2016/11/29 Javascript
bootstrap日历插件datetimepicker使用方法
2016/12/14 Javascript
浅谈Angular.js中使用$watch监听模型变化
2017/01/10 Javascript
微信小程序 新建登录页并实现tabBar隐藏
2017/06/13 Javascript
vue+vue-validator 表单验证功能的实现代码
2017/11/13 Javascript
JS防抖和节流实例解析
2019/09/24 Javascript
python算法学习之计数排序实例
2013/12/18 Python
Python设计模式编程中Adapter适配器模式的使用实例
2016/03/02 Python
Python引用模块和查找模块路径
2016/03/17 Python
TensorFlow 实战之实现卷积神经网络的实例讲解
2018/02/26 Python
python3.6使用pickle序列化class的方法
2018/10/22 Python
详解Python Matplotlib解决绘图X轴值不按数组排序问题
2019/08/05 Python
基于python中__add__函数的用法
2019/11/25 Python
手动安装python3.6的操作过程详解
2020/01/13 Python
OpenCV Python实现图像指定区域裁剪
2021/03/12 Python
Django URL参数Template反向解析
2020/11/24 Python
HTML5 Canvas像素处理使用接口介绍
2012/12/02 HTML / CSS
英国体育器材进口商店:UK Sport Imports
2017/03/14 全球购物
《孔子拜师》教学反思
2014/02/24 职场文书
《莫高窟》教学反思
2014/02/25 职场文书
弘扬焦裕禄精神走群众路线思想汇报
2014/09/12 职场文书
预备党员思想汇报1000字
2014/10/07 职场文书
民事起诉书范本
2015/05/19 职场文书
跟班学习心得体会(共6篇)
2016/01/23 职场文书
Java实现学生管理系统(IO版)
2022/02/24 Java/Android
再谈python_tkinter弹出对话框创建
2022/03/20 Python
MySQL数据库实验实现简单数据库应用系统设计
2022/06/21 MySQL