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. 发送数据给sap和接收

    1.确保已经连通sap 2.发送数据:这是以表的形式发送,而且是批量发送给sap 3.接收sap返回信息:这个比较特别,碰到时试一试 package com.yiyezhiqiu.lyh.utils; ...

  2. vue项目中解决跨域问题axios和

    项目如果是用脚手架搭建的(vue cli)项目配置文件里有个proxyTable proxyTable是vue-cli搭建webpack脚手架中的一个微型代理服务器,配置如下 配置和安装axios 安 ...

  3. 2019新生赛 %%%xxh

    笔记.md                                                                                                ...

  4. 2.2 selenium:org.openqa.selenium.WebDriverException: f.QueryInterface is not a function

    来源: http://blog.csdn.net/qiyueqinglian/article/details/47813271 URL中地址写不全的时候,就会报如题错误. url必须是完整的,比如ht ...

  5. 1.1Jmeter学习网站

    在网上找到一些关于Jmeter学习的博客等,在此标记 一. chinaunix的一篇博客,讲的蛮详细的 http://blog.chinaunix.net/uid/26884465/cid-16819 ...

  6. vue中的金额格式0.00 和 后台返回时间格式带T调整正常格式

    <template> <div class="consumption"> <p>{{payTime|Time}}</p> <p ...

  7. HahMap相关问题

    概述 文章对HashMap的部分细节进行介绍,JDK1.7之前有可能出现环形表的问题,而1.7之后进行了改进,文章对环形表现象的出现进行了解析,然后对HashMap注意的几个问题进行了解答. Hash ...

  8. Atcoder Beginner Contest 147D(按位处理)

    把每个数字每一位上二进制数字取出,求答案时直接用N个数里这一位是0的个数乘上这一位是1的个数然后乘上二的这一位次方,注意所有可能溢出的地方都要对mod取模. #define HAVE_STRUCT_T ...

  9. 163music 反爬分析

    # 网易163 音乐的  mp3下载 .mp3 下载的一个API吧 封 IP 的一种报错 网易云就给我返回了一个{"code":-460,"msg":" ...

  10. htm5实现 文件夹上传

    观察百度云上传,可以看到input type=file 的标签上加个一个属性“webkitdirectory”,加上次属性即可选择整个文件夹.