【问题标题】:Tensorflow AttributeError: 'NoneType' object has no attribute 'TF_DeleteStatus'Tensorflow AttributeError:“NoneType”对象没有属性“TF_DeleteStatus”
【发布时间】:2017-03-26 10:34:22
【问题描述】:

Tensorflow 给了我这个未解决的错误:

Exception ignored in: <bound method BaseSession.__del__ of <tensorflow.python.client.session.Session object at 0x7f68d14b6668>>
Traceback (most recent call last):
  File "/opt/anaconda3/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 532, in __del__
AttributeError: 'NoneType' object has no attribute 'TF_DeleteStatus'

该错误已讨论here。问题是它没有始终如一地出现。但是,它经常出现在我的终端中。有没有人设法绕过它。谢谢。

【问题讨论】:

  • 感谢您对 github 的评论。即将修复。

标签: python tensorflow keras


【解决方案1】:

在您的 TensorFlow keras 模型中编写代码...

from keras import backend as K
.
.
.
.
.
model.load_weights("modelname")
K.clear_session()

【讨论】:

    【解决方案2】:

    Github 的答案张贴在这里以节省时间:

    from keras import backend as K
    
    # ... code
    K.clear_session()
    

    我在代码中的 model.load_weights 调用之前添加了 K.clear_session() 并且有效。

    【讨论】:

      【解决方案3】:

      您需要删除 Tensorflow 会话以避免该消息。最简单的可能是使用with 语句:

      from keras import backend as K
      
      def main():
          with K.get_session():
              train()
              classify()
      

      【讨论】:

        【解决方案4】:

        您可以在代码末尾运行import gc; gc.collect()

        【讨论】:

        猜你喜欢
        • 2018-09-07
        • 2019-01-01
        • 2021-12-26
        • 2019-07-23
        • 2018-05-13
        • 2020-09-07
        • 2017-05-03
        • 2023-03-16
        • 2018-07-14
        相关资源
        最近更新 更多