tf.train.Saver()的定义与使用
Saver对象:用于在tf中保存,恢复Session
定义
model_path="/tmp/model.ckpt"
saver=tf.train.Saver()
Saver保存操作:saver.save(sess,model_path)
save_path=saver.save(sess,model_path)
Saver恢复操作:saver.restore(sess,save_path)
saver.restore(sess,model_path)
注意事项:
1.tf.train.Saver()定义在Session之前
2.saver.save()和saver.restore()都在Session里进行
tf.train.Saver()使用代码示例
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 19 22:59:41 2017
@author: ZMJ
"""
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
print "Package Loaded"
np.random.seed(1)
def f(x,weight,bias):