tensorflow1切换为tensorflow2报错CancelledError: Session has been closed.

桃扇骨 2023-03-06 05:03 44阅读 0赞

tensorflow1切换为tensorflow2报错CancelledError: Session has been closed.

报错信息

  1. ---------------------------------------------------------------------------
  2. CancelledError Traceback (most recent call last)
  3. <ipython-input-48-c60f2701b645> in <module>()
  4. ----> 7 multi_vgg.fit(1)
  5. <ipython-input-39-f26f8baed70a> in fit(s, steps, summary_step, checkpoint_step)
  6. 84 s.save_checkpoint()
  7. 85 coord.request_stop()
  8. ---> 86 coord.join(threads)
  9. 87 s.session.close()
  10. 88
  11. ~/anaconda3/lib/python3.6/site-packages/tensorflow/python/training/coordinator.py in join(self, threads, stop_grace_period_secs, ignore_live_threads)
  12. ~/anaconda3/lib/python3.6/site-packages/six.py in reraise(tp, value, tb)
  13. 701 if value.__traceback__ is not tb:
  14. 702 raise value.with_traceback(tb)
  15. --> 703 raise value
  16. 704 finally:
  17. 705 value = None
  18. ~/anaconda3/lib/python3.6/site-packages/tensorflow/python/training/queue_runner_impl.py in _run(self, sess, enqueue_op, coord)
  19. ~/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py in _single_operation_run()
  20. ~/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py in _call_tf_sessionrun(self, options, feed_dict, fetch_list, target_list, run_metadata)
  21. CancelledError: Session has been closed.

解决办法

  1. restart kernel(重启内核,重新运行jupyter)

发表评论

表情:
评论列表 (有 0 条评论,44人围观)

还没有评论,来说两句吧...

相关阅读