Keras: TypeError: 'NoneType' object is not callable

Created on 3 Feb 2018  路  17Comments  路  Source: keras-team/keras

My environment

python 3.5.2 anaconda (use pyenv)
keras 2.3.0
tensorflow 1.4.1
theano 1.0.1
cntk 2.3

When backend is tensorflow, TypeError occurs just before learning is finished.

TypeError: 'NoneType' object is not callable

Is there a solution?

Most helpful comment

I've been getting this issue as well. It only happens sometimes. It's unfortunate for it to happen after a long training session, as this prevents me from being able to save my models.

All 17 comments

I'm sorry...

keras version is 2.1.3

Can you please share a standalone code snippet that can help reproduce the problem?

Same problem happens using github/keras/examples/neural_doodle.py.

Using latest nvidia, cuda 9.0, tensorflow 1.5, keras installed by current pip3.

The same issue with Ubuntu native Python3(v3.5.2), Keras(v2.1.5) and Tensorflow(v1.6.0).
Traceback is below:

Exception ignored in: <bound method BaseSession.__del__ of <tensorflow.python.client.session.Session object at 0x7f8a8c2b1f98>>
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 712, in __del__
TypeError: 'NoneType' object is not callable

same issue

I had the same issue. But I tried it again, and it is working fine. It's weird.

I've been getting this issue as well. It only happens sometimes. It's unfortunate for it to happen after a long training session, as this prevents me from being able to save my models.

the same issue on tensorflow:1.7.1-devel-gup-py3 docker tags. Sometimes it works, while sometimes the issue occurs.

Same issue

Same here.

Python 3.5.2
Keras 2.1.5
Tensorflow 1.7

same issue
python 3.5
keras 2.1

same here
python 3.5.2
tensorflow 1.10.1 (with built-in keras)
pip 18.0

As a workaround you can fix the error by writing the below 2 lines of code at the end of training code.

import gc
gc.collect()

Same here
python 3.5
tensorflow 1.10
keras 2.2.4

I had the same issue. In my case, delete the __pycache__ was a workaround.
rm -rf /usr/lib/{PYTHON_VERSION}/__pycache__/

Same here
python 3.6.9
tensorflow 1.9

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zygmuntz picture zygmuntz  路  3Comments

braingineer picture braingineer  路  3Comments

Imorton-zd picture Imorton-zd  路  3Comments

KeironO picture KeironO  路  3Comments

anjishnu picture anjishnu  路  3Comments