TF随笔-11
#!/usr/bin/env python2 # -*- coding: utf-8 -*- import tensorflow as tf my_var=tf.Variable(0.) step=tf.Variable(0,trainable=False) ema=tf.train.ExponentialMovingAverage(0.99,step) maintain_average_op=ema.apply([my_var]) with tf.Session() as sess: init_op=tf.global_variables_initializer() sess.run(init_op) decay=0.99 #影子变量值变化 for i in range(1,6): print sess.run([my_var,ema.average(my_var)]) sess.run(my_var.assign_add(i)) sess.run(maintain_average_op) print sess.run([my_var,ema.average(my_var)]) print "===" print "----------------" #num_updates即step变化 sess.run(my_var.assign(5.)) for i in range(1,20,3): print sess.run([my_var,ema.average(my_var)]) sess.run(step.assign_add(i)) sess.run(maintain_average_op) print sess.run([my_var,ema.average(my_var)]) print "==="
滑动平均模型
shadow_variable= decay * shadow_variable + (1 - decay) * variable
Reasonable values for decay are close to 1.0, typically in themultiple-nines range: 0.999, 0.9999, etc.
The apply() methodadds shadow copies of trained variables and add ops that maintain a movingaverage of the trained variables in their shadow copies. It is used whenbuilding the training model.
The optional num_updates parameter allows one to tweak thedecay rate dynamically. It is typical to pass the count of training steps,usually kept in a variable that is incremented at each step, in which case thedecay rate is lower at the start of training. This makes moving averages movefaster. If passed, the actual decay rate used is:
min(decay, (1 +num_updates) / (10 + num_updates))
TF随笔-11的更多相关文章
- TF随笔-4
>>> import tensorflow as tf>>> a=tf.constant([[1,2],[3,4]])>>> b=tf.const ...
- TF随笔-13
import tensorflow as tf a=tf.constant(5) b=tf.constant(3) res1=tf.divide(a,b) res2=tf.div(a,b) with ...
- TF随笔-10
#!/usr/bin/env python# -*- coding: utf-8 -*-import tensorflow as tf x = tf.constant(2)y = tf.constan ...
- TF随笔-9
计算累加 #!/usr/bin/env python2 # -*- coding: utf-8 -*-"""Created on Mon Jul 24 08:25:41 ...
- TF随笔-8
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Mon Jul 10 09:35:04 201 ...
- TF随笔-7
求平均值的函数 reduce_mean axis为1表示求行 axis为0表示求列 >>> xxx=tf.constant([[1., 10.],[3.,30.]])>> ...
- tf随笔-6
import tensorflow as tfx=tf.constant([-0.2,0.5,43.98,-23.1,26.58])y=tf.clip_by_value(x,1e-10,1.0)ses ...
- tf随笔-5
# -*- coding: utf-8 -*-import tensorflow as tfw1=tf.Variable(tf.random_normal([2,6],stddev=1))w2=tf. ...
- TF随笔-3
>>> import tensorflow as tf>>> node1 = tf.constant(3.0, dtype=tf.float32)>>& ...
随机推荐
- hadoop yarn HA集群搭建
可先完成hadoop namenode HA的搭建:http://www.cnblogs.com/kisf/p/7458519.html 搭建yarnde HA只需要在namenode HA配置基础上 ...
- IoC控制反转与DI依赖输入
IoC (Inversion of Control)即控制反转,是面向对象编程中的一种设计原则.它把传统上由程序代码直接操控的对象的调用权交给容器,通过外部容器来实现对象组件的装配和管理. 简单来说, ...
- 实现在vista和win7中使用管理员权限接收WM_DROPFILES(OnDropFiles())消息的方法(好像XP不支持这个函数)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 #pragma once #ifndef WM_COPYGLOBALD ...
- c++ 使用WinHTTP实现文件下载功能
因为要项目中要想要实现一个软件自动更新的功能,之前是使用socket直接下载.但切换下载源的时候很麻烦.所以换用http方式. 网上找了很多资料,基本上就是下面几种: 1.curllib //功能强大 ...
- MR案例:WordCount改写
请参照wordcount实现一个自己的MapReduce,需求为: a. 输入文件格式: xxx,xxx,xxx,xxx,xxx,xxx,xxx b. 输出文件格式: ...
- Python多版本共存管理工具之pyenv
目录 Table of Contents 1. 安装pyenv 2. 安装Python 3.0 使用python 参考 Table of Contents 经常遇到这样的情况: 系统自带的Python ...
- 剑指Offer——最长不包含重复字符的子字符串
Solution 动态规划. f(i)表示包含第i个字符的最长子串. 如果第i个字符没在之前出现过,那么f(i) = f(i - 1) + 1 如果第i个字符在之前出现过,这个时候应该分两种情况,假设 ...
- 转:MySQL 的show processlist
processlist 命令的输出结果显示了有哪些线程在运行,可以帮助识别出有问题的查询语句,两种方式使用这个命令. 1. 进入 mysql/bin 目录下输入 mysqladmin p ...
- 从0开始 Java实习 黑白棋
黑白棋的设计 代码如下: import java.util.*; public class Chess{ char[][] chess = new char[16][16]; public stati ...
- Ubuntu下配置Nginx+PHP
1.安装Nginxapt-get install nginx 2.启动Nginxservice nginx start 3.访问服务器IP 如果看到“Welcome to nginx!”说明安装好了. ...