Keras Bug 解决方法 Exception ignored in: bound method BaseSession.__del__ of

报错信息

Exception ignored in: <bound method BaseSession.__del__ of <tensorflow.python.client.session.Session object at 0x000000001AB286D8>>
Traceback (most recent call last):
  File "python3.5.2\lib\site-packages\tensorflow\python\client\session.py", line xxx, in __del__
TypeError: 'NoneType' object is not callable

原因:Python垃圾回收机制在回收session对象时,发现 c_api_util 或 tf_session已经被回收了,造成了空指针。下面这段注释就是tensorflow源码中抛出异常时给出的原因

# At shutdown, `c_api_util` or `tf_session` may have been garbage
# collected, causing the above method calls to fail. In this case,
# silently leak since the program is about to terminate anyway.

解决方法

方法一:

import keras.backend as K

# your code

K.clear_session()

方法二:

import gc

# your code

gc.collect()

参考

https://github.com/tensorflow/tensorflow/issues/3388

https://www.cnblogs.com/kaituorensheng/p/4449457.html

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值