我在恢復保存的模型時遇到困難。我培養了CNN的MNIST數據集,所有根據MNIST教程Deep MNIST for Experts,我救了我的模型下面的代碼:如何在TensorFlow中導入模型
saver.save(sess, './Tensorflow_MNIST', global_step=max_steps)
這將創建下列文件:
- Tensorflow_MNIST- 1000.data 00000-的-00001
- Tensorflow_MNIST-1000.index
- Tensorflow_MNIST-1000.meta
- 關卡
後來我想加載模型,並繼續訓練:
with tf.Session() as sess:
new_saver = tf.train.import_meta_graph('./Tensorflow_MNIST-1000.meta')
new_saver.restore(sess, './Tensorflow_MNIST-1000')
batch_xs, batch_ys = mnist.train.next_batch(50)
sess.run(train_step, feed_dict[x: batch_xs, y_batch_ys, keep_prob:0.5])
然而,這會返回一個錯誤:
NameError: name 'train_step' is not defined
所以看起來像圖和它的變量和操作未正確加載。我在這裏做錯了什麼?