问答详情
源自:3-7 TensorFlow结合mnist进行卷积模型训练(4)

训练报错 train_accuracy = accuracy.eval(feed_dict={x: batch[0], y: batch[1], keep_prob: 1.0}) 不知道哪里出错了

Traceback (most recent call last):

  File "D:/user/pycharm/mnist_test/mnist/convolutional.py", line 27, in <module>

    train_accuracy = accuracy.eval(feed_dict={x: batch[0], y: batch[1], keep_prob: 1.0})

  File "D:\program files\Anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\framework\ops.py", line 680, in eval

    return _eval_using_default_session(self, feed_dict, self.graph, session)

  File "D:\program files\Anaconda\envs\tensorflow\lib\site-packages\tensorflow\python\framework\ops.py", line 4937, in _eval_using_default_session

    raise ValueError("Cannot evaluate tensor using `eval()`: No default "

ValueError: Cannot evaluate tensor using `eval()`: No default session is registered. Use `with sess.as_default()` or pass an explicit session to `eval(session=sess)`


Process finished with exit code 1


提问者:精慕门3471333 2018-11-09 02:16

个回答

  • niaiai
    2018-12-01 13:21:56

    train_accuracy = accuracy.eval(feed_dict={x: batch[0], y_: batch[1], keep_prob: 1.0})