No DL network type associated with Python type '<class 'tensorflow.python.framework.ops.Tensor'>' error

Dear Knimers

I’m getting the following error when running a simple Keras auto-encoder within the -DL Python Network Creator- node:

ERROR DL Python Network Creator 0:90       Execute failed: No deep learning network type associated with Python type '<class 'tensorflow.python.framework.ops.Tensor'>'.
Please check your assignment of 'output_network' within the script and make sure you are not missing any KNIME extensions.

This piece of python code used to work fine before but not anymore whatever the version I use of KNIME or the conda environment I set. The amazing thing is that if I run the Python code inside the node, I do not get any error and everything works fine. The error happens when the node tries to transfer the Keras model from Python to KNIME.

I’m including here a minimalist workflow with two DL Python Network Creator- nodes, the left one works fine whereas the 2nd one fails to transfer the Keras NN model and throws the above mentioned error:

20210906 DL Python Network Creator Execution Problem.knwf (88.5 KB)

Did anybody face this problem before and if fixed, could you please shed some light on how to solve it ? Your help will be greatly appreciated.

Best

Ael

Hi @aworker,

Could you try rephrasing line 41 to

output_network = autoencoder

and see if this fixes the problem? The output_network variable is expected to be of a Keras model type, whereas encoded is a Tensor.

Marcel

3 Likes

Hi @MarcelW

Thanks a lot for your prompt help. I really appreciate it :smiley: !

Your hint led me to the source of the problem. My code used to work a while ago but since then Keras and tensorflow have evolved. The Keras library I was calling exists but was encoding the Keras NN as a Tensorflow type:

as shown on the above highlighted snapshot.

I made the change you suggested plus the following:

From:

from tensorflow.keras.layers import Input, Dense, Conv2D, MaxPooling2D, UpSampling2D
from tensorflow.keras.models import Model

To:

from keras.layers import Input, Dense, Conv2D, MaxPooling2D, UpSampling2D
from keras.models import Model

and now the final model is definitely of Keras type. Many thanks @MarcelW :blush: :+1: !

Best wishes

Ael

2 Likes

Cool! Glad I could help :slight_smile:.

Yeah, the different TensorFlow/Keras versions can be a little confusing. And, right now, KNIME doesn’t really help to make the differences between the various versions (TensorFlow 1 vs 2, tensorflow.keras vs keras) more obvious. This is something we’re actively working on improving at the moment.

Marcel

2 Likes

Good news :blush: !

Thanks again and looking forward to trying the new improved versions !

Ael

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