I have a subclass model which trains fine with model.fit when using tf.config.experimental_run_functions_eagerly(True). When i try to run the model without the eager mode i get the following error.
Exception has occurred: ValueError
in user code:
File "/home/rwo/.local/lib/python3.10/site-packages/keras/engine/training.py", line 1021, in train_function *
return step_function(self, iterator)
File "/home/rwo/.local/lib/python3.10/site-packages/keras/engine/training.py", line 1010, in step_function **
outputs = model.distribute_strategy.run(run_step, args=(data,))
File "/home/rwo/.local/lib/python3.10/site-packages/keras/engine/training.py", line 1000, in run_step **
outputs = model.train_step(data)
File "/home/rwo/.local/lib/python3.10/site-packages/keras/engine/training.py", line 859, in train_step
y_pred = self(x, training=True)
File "/home/rwo/.local/lib/python3.10/site-packages/keras/utils/traceback_utils.py", line 67, in error_handler
raise e.with_traceback(filtered_tb) from None
ValueError: Exception encountered when calling layer "learned_transformation" (type LearnedTransformation).
in user code:
File "/home/rwo/Documents/Masterstudium/Studium/Masterarbeit/src/models/learned_transformation.py", line 115, in call *
microphone_channels = self.expand_reshape(inputs[0])
File "/home/rwo/.local/lib/python3.10/site-packages/keras/utils/traceback_utils.py", line 67, in error_handler **
raise e.with_traceback(filtered_tb) from None
ValueError: Exception encountered when calling layer "reshape" (type Reshape).
as_list() is not defined on an unknown TensorShape.
Call arguments received:
• inputs=tf.Tensor(shape=<unknown>, dtype=float32)
Call arguments received:
• inputs=('tf.Tensor(shape=<unknown>, dtype=float32)', 'tf.Tensor(shape=<unknown>, dtype=float32)')
• training=True
I use a tf.data dataset as input. The model has multiple inputs hence the indexed access. I have a minimal different model which trains with and without eager mode on the same dataset. Can someone give me a hint why the Tensorshape might be unknown? The other model seems to be able to infer the tensorshape from the dataset. Can someone give me a hint if this problem is caused by the dataset or the model?