TypeError: Tensors are unhashable (this tensor: KerasTensor(type_spec=TensorSpec(shape=(None, 80), dtype=tf.int32, name='input_1'), name='input_1', description="created by layer 'input_1'")). Instead, use tensor.ref() as the key.

Hi,

I am getting the following error when trying to use the Keras Network Learner in KNIME platform. Please guide me as to how I can fix this issue.

ERROR Keras Network Learner 3:16 Execute failed: An error occurred while creating the Keras network from its layer specifications. Details:
Tensors are unhashable (this tensor: KerasTensor(type_spec=TensorSpec(shape=(None, 80), dtype=tf.int32, name=‘input_1’), name=‘input_1’, description=“created by layer ‘input_1’”)). Instead, use tensor.ref() as the key.
Traceback (most recent call last):
File “”, line 5, in
File “D:\Internship\KNIME\plugins\org.knime.dl.python_4.5.0.v202111291525\py\DLPythonNetworkSpecToDataFrameConverter.py”, line 92, in get_layer_data_specs_as_data_frames
extractor = DLPythonNetworkSpecToDataFrameConverter(network.spec)
File “D:\Internship\KNIME\plugins\org.knime.dl.keras_4.5.0.v202108181631\py\DLKerasNetwork.py”, line 150, in spec
self._spec = self._extract_model_spec()
File “D:\Internship\KNIME\plugins\org.knime.dl.keras_4.5.0.v202108181631\py\DLKerasTensorFlowNetwork.py”, line 87, in _extract_model_spec
return DLKerasTensorFlowNetworkSpecExtractor(self._model).extract_spec()
File “D:\Internship\KNIME\plugins\org.knime.dl.keras_4.5.0.v202108181631\py\DLKerasNetworkSpecExtractor.py”, line 95, in extract_spec
self._extract_node_input_tensor_specs(layer, node_idx)
File “D:\Internship\KNIME\plugins\org.knime.dl.keras_4.5.0.v202108181631\py\DLKerasNetworkSpecExtractor.py”, line 149, in _extract_node_input_tensor_specs
if input_tensor in self._model_inputs and input_tensor not in self._visited_inputs:
File “C:\anaconda3\envs\py3_knime_dl\lib\site-packages\keras\engine\keras_tensor.py”, line 242, in hash
raise TypeError(f’Tensors are unhashable (this tensor: {self}). ’
TypeError: Tensors are unhashable (this tensor: KerasTensor(type_spec=TensorSpec(shape=(None, 80), dtype=tf.int32, name=‘input_1’), name=‘input_1’, description=“created by layer ‘input_1’”)). Instead, use tensor.ref() as the key.

Have you tried what the posted on github?

br

3 Likes

Oh it seems I have solved it already. Thanks for your response!

1 Like

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