Keras: An error occurred while communicating with Python


I have tried to embed a simple Keras model (tensorflow backend) to classify MNIST digits, which I trained in pyCharm. The model was saved as a standard h5 file and can be loaded and reused within pyCharm. Unfortunately, when I try to use the Network Reader Node I receive the following error message:

ERROR DL Keras Network Reader 2:17 An error occurred while communicating with Python (while reading in the Keras network).
Cause: An error occurred in Python: Traceback (most recent call last):
File “C:\Program Files\KNIME\plugins\org.knime.python2_3.5.0.v201712011355\py\”, line 491, in execute
exec(source_code, self._exec_env, self._exec_env)
File “”, line 3, in
File “C:\Program Files\KNIME\plugins\org.knime.dl.keras_3.5.3.v201804031044\py\”, line 61, in read
model = self._read_internal(path, compile)
File “C:\Program Files\KNIME\plugins\org.knime.dl.keras_3.5.3.v201804031044\py\”, line 97, in _read_internal
return load_model(path, compile=compile)
File “C:\Anaconda\envs\keras\lib\site-packages\keras\”, line 258, in load_model
File “C:\Anaconda\envs\keras\lib\site-packages\keras\”, line 689, in deserialize
File “C:\Anaconda\envs\keras\lib\site-packages\keras\utils\”, line 142, in deserialize_keras_object
return cls.from_config(config[‘config’])
File “C:\Anaconda\envs\keras\lib\site-packages\keras\”, line 127, in from_config
return cls(**config)
File “C:\Anaconda\envs\keras\lib\site-packages\keras\”, line 403, in init
super(Adam, self).init(**kwargs)
File “C:\Anaconda\envs\keras\lib\site-packages\keras\”, line 63, in init
'passed to optimizer: ’ + str(k))
TypeError: Unexpected keyword argument passed to optimizer: amsgrad

WARN DL Keras Network Reader 2:17 Failed to read deep learning network specification. See log for details.

I can train Keras models within KNIME as well as using Example Workflows which are using the Network Reader node (for instance the “classify_images_using_inceptionV3” workflow).
Any Idea what I’am doing wrong? Thanks in advance.

Edit: Okay it works if I do not use adam as my optimizer. Any Idea how to fix this?

Hi Niklas,

Do you use the same Keras version to load the network as you used to save it?


1 Like

Hi Marcel,

This was the first thing I checked but it seems that I messed up. I had keras 2.1.2 in my KNIME env and keras 2.2.0 in my pycharm env. Now it works. Thank you!


1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.