tensorflow 学习笔记10 网络模型的保存与提取
2017-08-19 18:35
501 查看
参数的保存与提取关键点就是前后参数的shape,name,dtype都必须一致:
参数的保存:
import tensorflow as tf
w = tf.Variable(tf.constant(1.0, shape=[1]), name="w")
b = tf.Variable(tf.constant(2.0, shape=[1]), name="b")
saver = tf.train.Saver()
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
saver.save(sess, "Model/model.ckpt")
参数的提取:
import tensorflow as tf
w = tf.Variable(tf.constant(0.0, shape=[1]), name="w")
b = tf.Variable(tf.constant(0.0, shape=[1]), name="b")
saver = tf.train.Saver()
with tf.Session() as sess:
saver.restore(sess, "./Model/model.ckpt")
print("w,b:",sess.run(w),sess.run(b))结果:
参数的保存:
import tensorflow as tf
w = tf.Variable(tf.constant(1.0, shape=[1]), name="w")
b = tf.Variable(tf.constant(2.0, shape=[1]), name="b")
saver = tf.train.Saver()
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
saver.save(sess, "Model/model.ckpt")
参数的提取:
import tensorflow as tf
w = tf.Variable(tf.constant(0.0, shape=[1]), name="w")
b = tf.Variable(tf.constant(0.0, shape=[1]), name="b")
saver = tf.train.Saver()
with tf.Session() as sess:
saver.restore(sess, "./Model/model.ckpt")
print("w,b:",sess.run(w),sess.run(b))结果:
相关文章推荐
- TensorFlow学习笔记--网络模型的保存和读取
- TensorFlow学习笔记10——TensorFlow保存和调用模型遇到的问题
- Tensorflow学习教程------模型参数和网络结构保存且载入,输入一张手写数字图片判断是几
- Tensorflow学习笔记:模型训练数据的保存和恢复的简单实例
- tensorflow学习笔记----二(CIFAR-10 模型 )
- tensorflow学习笔记六:保存和加载训练模型
- tensorflow 学习笔记(十一)- 模型的保存与恢复(Saver)
- 【深度学习】笔记4_caffe第二个比较经典的[小图片]识别例子CIFAR_10的运行,网络模型的详解
- tensorflow学习笔记--模型保存和恢复
- tensorflow笔记-简单模型训练,保存与提取
- Tensorflow学习笔记:CNN篇(8)——Finetuning,模型更为细化的保存与恢复
- Tensorflow学习笔记-模型保存与加载
- Tensorflow学习笔记-构建网络模型
- 深度学习笔记4--TensorFlow保存模型
- [TensorFlow]入门学习笔记(6)-Tensorboard简易教程和模型保存
- 【懒懒的Tensorflow学习笔记三之搭建简单的神经网络模型】
- Tensorflow学习笔记--模型保存与调取
- Tensorflow学习笔记:CNN篇(7)——Finetuning,模型的保存与恢复
- 【深度学习】笔记7: CNN训练Cifar-10技巧 ---如何进行实验,如何进行构建自己的网络模型,提高精度
- TensorFlow学习笔记2:构建CNN模型