Input tensor `model_1/hidden_layer/ReadVariableOp:0` enters the loop with shape (1, 500), but has shape (None, 500) after one iteration

I am currently using this notebook: GitHub - roemmele/keras-rnn-notebooks: Python notebooks that demonstrate simple RNN models for NLP tasks using Keras
As far as I know, this notebook worked with tensorflow==2.3.1. Now I have make this notebook work with tensorflow==2.15.0. The problem I have encountered is this.


I see the problem occurs when the input tensor passes the hidden layer in the model. The model is this.

How can I fix the problem? Do I have to use tf.while_loop’s shape_invariant parameter? Is there anyway not using tf.while_loop? Lowering the tensorflow version is not a given choice for me.

Thank you for reading this topic.

Hi @leejh9887, while creating the predictor_model could you please try by passing False value to the stateful argument. I have tried by doing that and did not face any error. Please refer to this gist for working code example. Thank You.