簡體   English   中英

Tensorflow AttributeError:'NoneType'對象沒有屬性'TF_DeleteStatus'

[英]Tensorflow AttributeError: 'NoneType' object has no attribute 'TF_DeleteStatus'

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'

這里討論了錯誤。 問題是它沒有始終如一地出現。 但是,它經常出現在我的終端中。 有沒有人設法繞過它。謝謝。

你可以運行import gc; gc.collect() 代碼末尾的import gc; gc.collect()

您需要刪除Tensorflow會話以避免該消息。 最簡單的可能是使用with語句:

from keras import backend as K

def main():
    with K.get_session():
        train()
        classify()

Github的回答發布在這里以節省時間:

from keras import backend as K

# ... code
K.clear_session()

我在我的代碼中調用了model.load_weights之前添加了K.clear_session() ,這很有效。

在tensorflow keras模型中編寫代碼......

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM