恢复已保存的模型

时间:2018-04-28 08:14:31

标签: python-3.x python-2.7 image-processing tensorflow mnist

我试图用tensorflow和mnist数据集预测手写数字。但我得到错误。我该如何解决错误?

import tensorflow as tf
.
.    #code
.    #code
.    #code
.
y_pred= tf.nn.softmax(layer3)  # USING SOFTMAX

init_op= tf.initialize_all_variables()
saver= tf.train.Saver()

# RESTORING MODEL
with tf.Session() as sess:
    sess.restore(sess, 'model.ckpt')
    sess.run(init_op)

    prediction= tf.argmax(y_pred, 1)
    print(prediction.eval(feed_dict={x: [imvalue],keep_prob: 1.0}
                       ,session=sess))

代码抛出以下错误:

Traceback (most recent call last):
  File "/home/monojit/writtenRecognition/digi.py", line 127, in <module>
sess.restore(sess, 'model.ckpt')
AttributeError: 'Session' object has no attribute 'restore'

0 个答案:

没有答案