模型保存读取参考
模型参数保存
保存时会把你里边定义的所有变量保存,W和b都会保存
import tensorflow as tf
import numpy as np
W = tf.Variable([[1,2,3],[3,4,5]], dtype=tf.float32, name='weights')
b = tf.Variable([[1,2,3]], 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, "my_net/save_net.ckpt")
print("Save to path: ", save_path)
读取模型参数
方法1-要重新定义相同参数的网络
这种方法,模型参数保存时定义了几个变量,读取时应该定义相同的变量
import t