我想將NN的參數儲存下次繼續學習
但發現儲存時似乎發生問題
叫出的參數每次都一樣
我的程式結構如下
還請強者指教
謝謝
class DQ:
def __init__():
self.sess = tf.Session()
saver = tf.train.Saver()
self.sess.run(tf.global_variables_initializer())
with tf.Session() as sess:
if os.path.isfile("save_net.ckpt.index"):
saver.restore(sess, "save_net.ckpt")
print('File exists, loading previous data!')
else:
# save_path = self.saver.save(self.sess, "save_net.ckpt")
print('File does not exist, starting fresh')
def _build_net(self):
省略
def learn(self,save_step):
saver = tf.train.Saver()
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
save_path = saver.save(sess, "save_net.ckpt")
print('save parameters')