Fix Keras Network Learner

Hi,

I am using the keras network learner node. However the following error occurs when I run it: “Execute failed: An error occured during training of the Keras deep learning network. See log for details.”

In the log I found the following

2024-01-19 03:11:15,878 : ERROR : KNIME-Worker-0-Keras Network Learner 5:89 :  : DLKerasLearnerNodeModel : Keras Network Learner : 5:89 : An error occurred while communicating with Python (while reading in the Keras network).
2024-01-19 03:11:15,879 : ERROR : KNIME-Worker-0-Keras Network Learner 5:89 :  : Node : Keras Network Learner : 5:89 : Execute failed: An error occured during training of the Keras deep learning network. See log for details.
java.lang.RuntimeException: An error occured during training of the Keras deep learning network. See log for details.
	at org.knime.dl.keras.base.nodes.learner.DLKerasLearnerNodeModel.handleGeneralException(DLKerasLearnerNodeModel.java:751)
	at org.knime.dl.keras.base.nodes.learner.DLKerasLearnerNodeModel.executeInternal(DLKerasLearnerNodeModel.java:721)
	at org.knime.dl.keras.base.nodes.learner.DLKerasLearnerNodeModel.execute(DLKerasLearnerNodeModel.java:320)
	at org.knime.core.node.NodeModel.executeModel(NodeModel.java:588)
	at org.knime.core.node.Node.invokeFullyNodeModelExecute(Node.java:1297)
	at org.knime.core.node.Node.execute(Node.java:1059)
	at org.knime.core.node.workflow.NativeNodeContainer.performExecuteNode(NativeNodeContainer.java:595)
	at org.knime.core.node.exec.LocalNodeExecutionJob.mainExecute(LocalNodeExecutionJob.java:98)
	at org.knime.core.node.workflow.NodeExecutionJob.internalRun(NodeExecutionJob.java:201)
	at org.knime.core.node.workflow.NodeExecutionJob.run(NodeExecutionJob.java:117)
	at org.knime.core.util.ThreadUtils$RunnableWithContextImpl.runWithContext(ThreadUtils.java:367)
	at org.knime.core.util.ThreadUtils$RunnableWithContext.run(ThreadUtils.java:221)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
	at org.knime.core.util.ThreadPool$MyFuture.run(ThreadPool.java:123)
	at org.knime.core.util.ThreadPool$Worker.run(ThreadPool.java:246)
Caused by: java.io.IOException: An error occurred while communicating with Python (while reading in the Keras network).
	at org.knime.dl.keras.core.DLKerasAbstractNetworkLoader.loadInternal(DLKerasAbstractNetworkLoader.java:177)
	at org.knime.dl.keras.core.DLKerasAbstractNetworkLoader.load(DLKerasAbstractNetworkLoader.java:130)
	at org.knime.dl.keras.core.DLKerasAbstractNetworkLoader.load(DLKerasAbstractNetworkLoader.java:1)
	at org.knime.dl.python.core.training.DLPythonAbstractNetworkTrainingSession.trainInternal(DLPythonAbstractNetworkTrainingSession.java:190)
	at org.knime.dl.core.training.DLAbstractNetworkTrainingSession.run(DLAbstractNetworkTrainingSession.java:273)
	at org.knime.dl.keras.base.nodes.learner.DLKerasLearnerNodeModel.executeInternal(DLKerasLearnerNodeModel.java:712)
	... 14 more
Caused by: org.knime.python2.kernel.PythonIOException: 'str' object has no attribute 'decode'
Traceback (most recent call last):
  File "<string>", line 3, in <module>
  File "C:\Users\me\AppData\Local\Programs\KNIME\plugins\org.knime.dl.keras_5.2.0.v202310301554\py\DLTF2NetworkReader.py", line 126, in read
    return read_keras(self.backend, path, compile, compatibility_mode)
  File "C:\Users\me\AppData\Local\Programs\KNIME\plugins\org.knime.dl.keras_5.2.0.v202310301554\py\DLTF2NetworkReader.py", line 92, in read_keras
    }[backend](path, compile, compatibility_mode)
  File "C:\Users\me\AppData\Local\Programs\KNIME\plugins\org.knime.dl.keras_5.2.0.v202310301554\py\DLTF2NetworkReader.py", line 98, in read_keras_tensorflow
    compatibility_mode=compatibility_mode)
  File "C:\Users\me\AppData\Local\Programs\KNIME\plugins\org.knime.dl.keras_5.2.0.v202310301554\py\DLKerasTensorFlowNetwork.py", line 60, in read
    model = self._read_internal(path, compile)
  File "C:\Users\me\AppData\Local\Programs\KNIME\plugins\org.knime.dl.keras_5.2.0.v202310301554\py\DLKerasNetwork.py", line 100, in _read_internal
    return load_model(path, compile=compile)
  File "C:\Users\me\AppData\Local\anaconda3\envs\newEnv\lib\site-packages\keras\engine\saving.py", line 419, in load_model
    model = _deserialize_model(f, custom_objects, compile)
  File "C:\Users\me\AppData\Local\anaconda3\envs\newEnv\lib\site-packages\keras\engine\saving.py", line 224, in _deserialize_model
    model_config = json.loads(model_config.decode('utf-8'))
AttributeError: 'str' object has no attribute 'decode'

	at org.knime.python2.kernel.Python2KernelBackend.executeCommand(Python2KernelBackend.java:1282)
	at org.knime.python2.kernel.Python2KernelBackend.execute(Python2KernelBackend.java:1238)
	at org.knime.python2.kernel.Python2KernelBackend.lambda$10(Python2KernelBackend.java:1244)
	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)

I’ve deduced that I must be running Python 2.0 somewhere but I genuinely wouldn’t know where.

Below is my python preferences

, Python Legacy


,

Python Deep Learning


.

Any pointers on what may be wrong?