美文网首页
Keras - 'NoneType' objec

Keras - 'NoneType' objec

作者: 闫_锋 | 来源:发表于2018-06-04 18:47 被阅读5次

问题描述:
Exception ignored in: <bound method BaseSession.del of <tensorflow.python.client.session.Session object at 0x7fb4ecd301d0>>
Traceback (most recent call last):
File "/home/magnus/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 171, in del
File "/home/magnus/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 167, in close
AttributeError: 'NoneType' object has no attribute 'raise_exception_on_not_ok_status'

Process finished with exit code 0


解决方案:
it induced by different gc sequence, if python collect session first , the program will exit successfully, if python collect swig memory(tf_session) first, the program exit with failure.

you can force python to del session by:

del session

or if you are using keras, you cant get the session instance, you can run following code at end of your code:

import gc; gc.collect()
with tf.Session() as session:
    session.run(...)
del session

原链接:
https://github.com/tensorflow/tensorflow/issues/3388

相关文章

网友评论

      本文标题:Keras - 'NoneType' objec

      本文链接:https://www.haomeiwen.com/subject/jziysftx.html