DL Example generates error - Keras Network Learner

I am trying to run the

Multivariate Time Series Analysis with an RNN - Training
example.

I am getting the following error

Keras Network Learner

Execute failed: An error occurred while creating the Keras network from its layer specifications. Details: No module named 'pandas.util.testing' Traceback (most recent call last): File "<string>", line 2, in <module> File "/home/kurt/Downloads/KNIME/knime_5.2.0/plugins/org.knime.dl.python_5.4.0.v202407310837/py/DLPythonNetwork.py", line 53, in <module> from pandas.util.testing import network ModuleNotFoundError: No module named 'pandas.util.testing'

I have been trying with various settings for Python and Deep Learning, as there some constellations not working because the are not consistent.

Now the settings are as shown in the attached images.

I also attach the relevant part of the knime.log,
Below is an excerpt of the installed versions of the relevant libs.

$ conda list |grep "pandas\|keras\|numpy\|tensorflow\|python"
ipython                   8.18.1             pyh707e725_3    conda-forge
keras                     2.4.3                hd3eb1b0_0  
keras-base                2.4.3              pyhd3eb1b0_0  
keras-preprocessing       1.1.2              pyhd3eb1b0_0  
numpy                     1.23.5           py39hf838250_0  
numpy-base                1.23.5           py39h1e6e340_0  
pandas                    2.2.3            py39h3b40f6f_1    conda-forge
python                    3.9.19          h0755675_0_cpython    conda-forge
python-dateutil           2.9.0.post0        pyhff2d567_1    conda-forge
python-fastjsonschema     2.21.1             pyhd8ed1ab_0    conda-forge
python-flatbuffers        1.12               pyhd8ed1ab_1    conda-forge
python-tzdata             2025.2             pyhd8ed1ab_0    conda-forge
python_abi                3.9                      5_cp39    conda-forge
tensorflow                2.4.1           mkl_py39h4683426_0  
tensorflow-base           2.4.1           mkl_py39h43e0292_0  
tensorflow-estimator      2.6.0              pyh7b7c402_0  

My questions now, How can I get the example to work?




knime.log (3.6 KB)

Env:
KNIME 5.4.3
no updates outstanding

LINUX MINT 21.3 Cinnamon
no updates outstanding

Hi @kludikovsky,

Thanks for reporting this.

The error is caused by an unnecessary import (pandas.util.testing) on our side, which we’ve now removed internally.

That said, if you’re using a newer version of pandas (≥ 1.3.0), this import will fail since it was removed upstream. So in the meantime, you can resolve this by creating a fresh Python environment with an older version of pandas, such as 1.2.5.

Best,
Keerthan

2 Likes

I have now downgraded pandas to 1.2.5 and the environment is as follows

$ conda list |grep "pandas\|keras\|numpy\|tensorflow\|python"
ipython                   8.18.1             pyh707e725_3    conda-forge
keras                     2.4.3                hd3eb1b0_0  
keras-base                2.4.3              pyhd3eb1b0_0  
keras-preprocessing       1.1.2              pyhd3eb1b0_0  
numpy                     1.23.5           py39hf838250_0  
numpy-base                1.23.5           py39h1e6e340_0  
pandas                    1.2.5            py39h295c915_0  
python                    3.9.19          h0755675_0_cpython    conda-forge
python-dateutil           2.9.0.post0        pyhff2d567_1    conda-forge
python-fastjsonschema     2.21.1             pyhd8ed1ab_0    conda-forge
python-flatbuffers        1.12               pyhd8ed1ab_1    conda-forge
python-tzdata             2025.2             pyhd8ed1ab_0    conda-forge
python_abi                3.9                      5_cp39    conda-forge
tensorflow                2.4.1           mkl_py39h4683426_0  
tensorflow-base           2.4.1           mkl_py39h43e0292_0  
tensorflow-estimator      2.6.0              pyh7b7c402_0  

But this results in the following error

Keras Network Learner

Execute failed: An error occurred while creating the Keras network from its layer specifications. Details: Cannot convert a symbolic Tensor (lstm_1/strided_slice:0) to a numpy array. This error may indicate that you're trying to pass a Tensor to a NumPy call, which is not supported Traceback (most recent call last): File "<string>", line 5, in <module> File "/home/kurt/anaconda3/envs/py3_DL/lib/python3.9/site-packages/tensorflow/python/keras/layers/recurrent.py", line 660, in __call__ return super(RNN, self).__call__(inputs, **kwargs) File "/home/kurt/anaconda3/envs/py3_DL/lib/python3.9/site-packages/tensorflow/python/keras/engine/base_layer.py", line 951, in __call__ return self._functional_construction_call(inputs, args, kwargs, File "/home/kurt/anaconda3/envs/py3_DL/lib/python3.9/site-packages/tensorflow/python/keras/engine/base_layer.py", line 1090, in _functional_construction_call outputs = self._keras_tensor_symbolic_call( File "/home/kurt/anaconda3/envs/py3_DL/lib/python3.9/site-packages/tensorflow/python/keras/engine/base_layer.py", line 822, in _keras_tensor_symbolic_call return self._infer_output_signature(inputs, args, kwargs, input_masks) File "/home/kurt/anaconda3/envs/py3_DL/lib/python3.9/site-packages/tensorflow/python/keras/engine/base_layer.py", line 863, in _infer_output_signature outputs = call_fn(inputs, *args, **kwargs) File "/home/kurt/anaconda3/envs/py3_DL/lib/python3.9/site-packages/tensorflow/python/keras/layers/recurrent_v2.py", line 1157, in call inputs, initial_state, _ = self._process_inputs(inputs, initial_state, None) File "/home/kurt/anaconda3/envs/py3_DL/lib/python3.9/site-packages/tensorflow/python/keras/layers/recurrent.py", line 859, in _process_inputs initial_state = self.get_initial_state(inputs) File "/home/kurt/anaconda3/envs/py3_DL/lib/python3.9/site-packages/tensorflow/python/keras/layers/recurrent.py", line 642, in get_initial_state init_state = get_initial_state_fn( File "/home/kurt/anaconda3/envs/py3_DL/lib/python3.9/site-packages/tensorflow/python/keras/layers/recurrent.py", line 2506, in get_initial_state return list(_generate_zero_filled_state_for_cell( File "/home/kurt/anaconda3/envs/py3_DL/lib/python3.9/site-packages/tensorflow/python/keras/layers/recurrent.py", line 2987, in _generate_zero_filled_state_for_cell return _generate_zero_filled_state(batch_size, cell.state_size, dtype) File "/home/kurt/anaconda3/envs/py3_DL/lib/python3.9/site-packages/tensorflow/python/keras/layers/recurrent.py", line 3003, in _generate_zero_filled_state return nest.map_structure(create_zeros, state_size) File "/home/kurt/anaconda3/envs/py3_DL/lib/python3.9/site-packages/tensorflow/python/util/nest.py", line 659, in map_structure structure[0], [func(*x) for x in entries], File "/home/kurt/anaconda3/envs/py3_DL/lib/python3.9/site-packages/tensorflow/python/util/nest.py", line 659, in <listcomp> structure[0], [func(*x) for x in entries], File "/home/kurt/anaconda3/envs/py3_DL/lib/python3.9/site-packages/tensorflow/python/keras/layers/recurrent.py", line 3000, in create_zeros return array_ops.zeros(init_state_size, dtype=dtype) File "/home/kurt/anaconda3/envs/py3_DL/lib/python3.9/site-packages/tensorflow/python/util/dispatch.py", line 201, in wrapper return target(*args, **kwargs) File "/home/kurt/anaconda3/envs/py3_DL/lib/python3.9/site-packages/tensorflow/python/ops/array_ops.py", line 2819, in wrapped tensor = fun(*args, **kwargs) File "/home/kurt/anaconda3/envs/py3_DL/lib/python3.9/site-packages/tensorflow/python/ops/array_ops.py", line 2868, in zeros output = _constant_if_small(zero, shape, dtype, name) File "/home/kurt/anaconda3/envs/py3_DL/lib/python3.9/site-packages/tensorflow/python/ops/array_ops.py", line 2804, in _constant_if_small if np.prod(shape) < 1000: File "<__array_function__ internals>", line 180, in prod File "/home/kurt/anaconda3/envs/py3_DL/lib/python3.9/site-packages/numpy/core/fromnumeric.py", line 3045, in prod return _wrapreduction(a, np.multiply, 'prod', axis, dtype, out, File "/home/kurt/anaconda3/envs/py3_DL/lib/python3.9/site-packages/numpy/core/fromnumeric.py", line 86, in _wrapreduction return ufunc.reduce(obj, axis, dtype, out, **passkwargs) File "/home/kurt/anaconda3/envs/py3_DL/lib/python3.9/site-packages/tensorflow/python/framework/ops.py", line 852, in __array__ raise NotImplementedError( NotImplementedError: Cannot convert a symbolic Tensor (lstm_1/strided_slice:0) to a numpy array. This error may indicate that you're trying to pass a Tensor to a NumPy call, which is not supported

Hi @kludikovsky ,

I’m sorry for the troubles you’re facing.

This thread here: An error occurred during training of the Keras deep learning network explains that the Keras nodes in KNIME require TensorFlow 1.x to work correctly.

Could you try switching your Python environment used for the DL Scripting nodes to one that uses Keras (standalone) and use TensorFlow 1.x (e.g., tensorflow==1.14)?

Or you can try using this workflow from @mlauber71: Sentiment Analysis - Setup with Conda Propagation. This uses the Conda Environment Propagation node, which automatically sets up a Python environment with all required packages for you.

Hope this helps.

Best,
Keerthan

2 Likes

@kludikovsky currently the use of DeepLearning nodes with KNIME is sometimes tricky. The nodes will require very specific combinations of python DL libraries that are not that easy to get - even more so if you try running this on Apple Silicon. What I know about I have written down here:

2 Likes