Exception ignored in: bound method basesession__ del__ Of

Error message

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

Reason: When the Python garbage collection mechanism collects the Session object, it finds that c_api_util or Tf_session has been collected, resulting in a null pointer. The following comment is the reason given when an exception is thrown in the source code of 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.

The solution
Method one:

import keras.backend as K

# your code

K.clear_session()

Method 2:

import gc

# your code

gc.collect()

reference
https://github.com/tensorflow/tensorflow/issues/3388
https://www.cnblogs.com/kaituorensheng/p/4449457.html


Read More: