密钥权重/检查点张量流中找不到变量

时间:2018-01-12 20:36:44

标签: python tensorflow

尝试加载训练有素的张量流模型,但是它出现了这个错误消息:

NotFoundError(参见上面的回溯):密钥权重/检查点中找不到变量      [[节点:save / RestoreV2_1 = RestoreV2 [dtypes = [DT_FLOAT],_ device =“/ job:localhost / replica:0 / task:0 / device:CPU:0”](_ arg_save / Const_0_0,save / RestoreV2_1 / tensor_names,保存/ RestoreV2_1 / shape_and_slices)]]

关于重量可能发生什么的任何想法,或者我如何恢复它们?或者我只是恢复模型错误?

以下是相关代码:

saver = tf.train.Saver()

with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    for i in range(20000):
        batch = mnist.train.next_batch(50)
            if i % 100 == 0:
                train_accuracy = accuracy.eval(feed_dict={
                    x: batch[0], y_: batch[1], keep_prob: 1.0})
                print('step %d, training accuracy %g' % (i, train_accuracy))
                saver.save(sess,"/Users/prakash/Desktop/hackathon/Trained_Data/modelstep.ckpt",global_step=i)
                print "saved ",i

        train_step.run(feed_dict={x: batch[0], y_: batch[1], keep_prob: 0.5})

    saver.save(sess,"/Users/prakash/Desktop/hackathon/Trained_Data/model.ckpt")
    print('test accuracy %g' % accuracy.eval(feed_dict={
    x: mnist.test.images, y_: mnist.test.labels, keep_prob: 1.0}))

以下是我试图恢复的方式:

saver.restore(sess,"Trained_Data/modelstep.ckpt")

0 个答案:

没有答案