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)>>& ...
随机推荐
- Net_Prop 之 CTerrorPlayer 属性
Sub-Class Table (1 Deep): DT_TerrorPlayer Sub-Class Table (2 Deep): DT_CSPlayer Sub-Class Table (3 D ...
- git-修改远程的URL
git remote set-url命令修改remote URL git remote set-url传递两个参数 remote name.例如,origin或者upstream new remote ...
- 百度开源分布式id生成器uid-generator源码剖析
百度uid-generator源码 https://github.com/baidu/uid-generator snowflake算法 uid-generator是基于Twitter开源的snowf ...
- Android Studio开发学习 - 1. 添加Activity
1. 项目上点右键,New -> Activity -> Blank Activity 这将生成Activity的 Layout.Class .和相关的配置信息(在AndroidManif ...
- 【bzoj4976】宝石镶嵌(思维dp)
题目传送门:bzoj4976 不得不说这是道脑洞dp,思路真的清奇. 我们可以发现,虽然n很大,但是k只有100,这里面似乎隐藏了什么玄机. 我们可以发现,设总共有$ tot $个二进制位在这n个数中 ...
- 【eclipse】启动不了报错java was started but returned exit code=13
原因是jdk与eclipse的版本不对,一个是32位的一个是64位的.
- springboot Actuator健康检查
通过情况下,如我们想在系统中添加一个健康检查的接口,我们怎么做呢? 我们会新建一个类,或在已存在类的基础上添加检测接口. package com.crhms.medicareopinion; impo ...
- 一款简单易用的.Net 断言测试框架 : Shouldly
GitHub地址:https://github.com/shouldly/shouldly Shouldly的官方文档:http://docs.shouldly-lib.net/ Nuget安装: 在 ...
- C# 操作FTP
操作FTP管理类: using System; using System.Collections.Generic; using System.Text; using System.Net; using ...
- 贯众云平台脚本编写之判断、循环以及shell命令的使用
最近使用贯众云平台工具写脚本,进行Ui界面的自动化测试.刚开始接触,确实碰到不少的问题,稍微难点的就是判断语句,循环语句以及shell命令的使用,尤其是对于咱们测试这样比较少接触代码的人来说. 其实吧 ...