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 25 Python
python读取Android permission文件
Nov 01 Python
Python实现的HTTP并发测试完整示例
Apr 23 Python
教大家使用Python SqlAlchemy
Feb 12 Python
python3+PyQt5实现自定义流体混合窗口部件
Apr 24 Python
Python实现正整数分解质因数操作示例
Aug 01 Python
利用Python正则表达式过滤敏感词的方法
Jan 21 Python
Python实现简单查找最长子串功能示例
Feb 26 Python
Python字典深浅拷贝与循环方式方法详解
Feb 09 Python
jupyter notebook的安装与使用详解
May 18 Python
PyTorch的torch.cat用法
Jun 28 Python
python批量生成身份证号到Excel的两种方法实例
Jan 14 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的substr_replace将指定两位置之间的字符替换为*号
2011/05/04 PHP
CodeIgniter启用缓存和清除缓存的方法
2014/06/12 PHP
php中实现用数组妩媚地生成要执行的sql语句
2015/07/10 PHP
深入剖析PHP中printf()函数格式化使用
2016/05/23 PHP
在 Laravel 中动态隐藏 API 字段的方法
2019/10/25 PHP
PHP 进程池与轮询调度算法实现多任务的示例代码
2019/11/26 PHP
对联广告js flash激活
2006/10/19 Javascript
利用腾讯的ip地址库做ip物理地址定位
2010/07/24 Javascript
jquery动画3.创建一个带遮罩效果的图片走廊
2012/08/24 Javascript
jquery 设置元素相对于另一个元素的top值(实例代码)
2013/11/06 Javascript
js实现键盘Enter键提交表单的方法
2015/05/27 Javascript
JS面向对象编程详解
2016/03/06 Javascript
微信小程序-横向滑动scroll-view隐藏滚动条
2017/04/20 Javascript
微信小程序导航栏滑动定位功能示例(实现CSS3的positionsticky效果)
2019/01/24 Javascript
vue实现弹幕功能
2019/10/25 Javascript
js实现随机点名程序
2020/09/17 Javascript
JS代码检查工具ESLint介绍与使用方法
2020/02/04 Javascript
keep-alive保持组件状态的方法
2020/12/02 Javascript
vue+elementUI动态增加表单项并添加验证的代码详解
2020/12/17 Vue.js
[02:26]2016国际邀请赛8月3日开战 中国军团出征西雅图
2016/08/02 DOTA
[47:43]完美世界DOTA2联赛PWL S3 Magama vs GXR 第二场 12.19
2020/12/24 DOTA
Python matplotlib通过plt.scatter画空心圆标记出特定的点方法
2018/12/13 Python
pycharm 实现显示project 选项卡的方法
2019/01/17 Python
Keras中 ImageDataGenerator函数的参数用法
2020/07/03 Python
CSS3实现的文本3D效果附图
2014/09/03 HTML / CSS
CSS3实现可爱的小黄人动画
2016/07/11 HTML / CSS
HTML5事件方法全部汇总
2016/05/12 HTML / CSS
深入浅析HTML5中的article和section的区别
2018/05/15 HTML / CSS
俄罗斯运动、健康和美容产品在线商店:Lactomin.ru
2020/07/23 全球购物
财务管理专业求职信
2014/06/11 职场文书
搞笑的获奖感言
2014/08/16 职场文书
中学生关于梦想的演讲稿
2014/08/22 职场文书
入党函调证明材料
2014/12/24 职场文书
公司欠款证明
2015/06/24 职场文书
《文化苦旅》读后感:阅读,让人诗意地栖居在大地上
2019/12/24 职场文书
MySQL表锁、行锁、排它锁及共享锁的使用详解
2022/04/02 MySQL