tensorflow1.0 模型的保存与加载

import tensorflow as tf
import numpy as np # ##Save to file
# W = tf.Variable([[4,5,6],[7,8,9]],dtype=tf.float32,name="weight")
# b = tf.Variable([[2,5,8]],dtype=tf.float32,name="biases")
#
# init = tf.initialize_all_variables()
#
# saver = tf.train.Saver()
#
# with tf.Session() as sess:
# sess.run(init)
# save_path = saver.save(sess,"models/model.ckpt")
# print("save complete") W = tf.Variable(np.arange(6).reshape((2,3)),dtype=tf.float32,name="weight")
b = tf.Variable(np.arange(3).reshape((1,3)),dtype=tf.float32,name="biases") saver = tf.train.Saver() with tf.Session() as sess:
saver.restore(sess,"models/model.ckpt")
print(sess.run(W))
print(sess.run(b))

  

[[4. 5. 6.]
[7. 8. 9.]]
[[2. 5. 8.]]

上一篇:pytorch 中模型的保存与加载,增量训练


下一篇:fashion_mnist多分类训练,两种模型的保存与加载