import tensorflow as tf

v = tf.Variable(0, dtype=tf.float32, name="v")
for variables in tf.global_variables():
print(variables.name) ema = tf.train.ExponentialMovingAverage(0.99)
maintain_averages_op = ema.apply(tf.global_variables())
for variables in tf.global_variables():
print(variables.name)

saver = tf.train.Saver()
with tf.Session() as sess:
init_op = tf.global_variables_initializer()
sess.run(init_op)
sess.run(tf.assign(v, 10))
sess.run(maintain_averages_op)
# 保存的时候会将v:0 v/ExponentialMovingAverage:0这两个变量都存下来。
saver.save(sess, "E:\\Saved_model\\model2.ckpt")
print(sess.run([v, ema.average(v)]))

v = tf.Variable(0, dtype=tf.float32, name="v")

# 通过变量重命名将原来变量v的滑动平均值直接赋值给v。
saver = tf.train.Saver({"v/ExponentialMovingAverage": v})
with tf.Session() as sess:
saver.restore(sess, "E:\\Saved_model\\model2.ckpt")
print sess.run(v)

吴裕雄 python 神经网络——TensorFlow 滑动平均类的保存的更多相关文章

  1. 吴裕雄 PYTHON 神经网络——TENSORFLOW 滑动平均模型

    import tensorflow as tf v1 = tf.Variable(0, dtype=tf.float32) step = tf.Variable(0, trainable=False) ...

  2. 吴裕雄 python 神经网络——TensorFlow训练神经网络:不使用滑动平均

    import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data INPUT_NODE = 784 ...

  3. 吴裕雄 python 神经网络——TensorFlow训练神经网络:不使用隐藏层

    import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data INPUT_NODE = 784 ...

  4. 吴裕雄 python 神经网络——TensorFlow训练神经网络:不使用激活函数

    import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data INPUT_NODE = 784 ...

  5. 吴裕雄 python 神经网络——TensorFlow训练神经网络:不使用指数衰减的学习率

    import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data INPUT_NODE = 784 ...

  6. 吴裕雄 python 神经网络——TensorFlow训练神经网络:不使用正则化

    import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data INPUT_NODE = 784 ...

  7. 吴裕雄 python 神经网络——TensorFlow训练神经网络:全模型

    import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data INPUT_NODE = 784 ...

  8. 吴裕雄 python 神经网络TensorFlow实现LeNet模型处理手写数字识别MNIST数据集

    import tensorflow as tf tf.reset_default_graph() # 配置神经网络的参数 INPUT_NODE = 784 OUTPUT_NODE = 10 IMAGE ...

  9. 吴裕雄 python 神经网络——TensorFlow 实现LeNet-5模型处理MNIST手写数据集

    import os import numpy as np import tensorflow as tf from tensorflow.examples.tutorials.mnist import ...

随机推荐

  1. 题解【洛谷P1046】[NOIP2005普及组] 陶陶摘苹果

    [NOIP2005] 陶陶摘苹果 首先,我们用一个数组s[11]存储每个苹果的高度. 然后,用a表示陶陶的身高. 接着,用a+30与s[i]比较,大于则计数器加一. 最后,输出计数器的值即可. #in ...

  2. Linux - 查看静态硬件信息

    概述 查看系统的 信息 一些 相对静态 的信息 背景 一直想写, 但是没来得及整理 每次要用的时候, 都慌里慌张的到处找 这次把他记下来 环境 CentOS 7 下面有些方法, 可能是 centos ...

  3. Jenkins Pipeline waitForQualityGate pending 超时

    请参考链接:http://www.iotxing.com/2019/06/12/258/jenkins-pipeline-waitforqualitygate%E8%B6%85%E6%97%B6/ 主 ...

  4. 【C 语言】一元二次方程

    求一元二次方程:ax2+bx+c=0 的根. 输入三个实数a,b,c的值,且a不等于0. 数学基础:一元二次方程 只含有一个未知数(一元),并且未知数项的最高次数是2(二次)的整式方程叫做一元二次方程 ...

  5. Codeforces A. Serval and Bus

    inputstandard inputoutputstandard outputIt is raining heavily. But this is the first day for Serval, ...

  6. php提供下载服务实例

    两个步骤:1,通过header头信息告诉浏览器,我给你回应的是一个附件请接收 2,通过php读取下载的文件的内容并返回 前端 <!DOCTYPE html> <html lang=& ...

  7. JVM中的动态语言支持简介

    抽丝剥茧 细说架构那些事——[优锐课] 从版本6开始,JVM已扩展为支持现代动态语言(也称为脚本语言).Java8的发行为这一领域提供了更多动力.感到这种支持的必要性是因为Java作为一种语言固有地是 ...

  8. 【网易官方】极客战记(codecombat)攻略-地牢-Kithmaze 二度历险

    关卡连接: https://codecombat.163.com/play/level/the-second-kithmaze 很多人试过,但只有少数人能穿过此迷宫. 简介: 记住,你只需 一个 wh ...

  9. Bug搬运工-CSCvg37458:ISR4K goes into booting loop with "flash:" in boot statement

    ISR4K升级的时候要注意了! 很可能会碰到如下的问题: ISR4K goes into booting loop with "flash:" in boot statement ...

  10. bodyParser.urlencoded({ })里extended: true和false区别???