Layer 'lstm_cell' expected 3 variables, but received 0

I am using databricks to train my models, and I test them locally

I would like to experiment with bi-directional lstm, I am facing issues to load the trained model after being saved.

ValueError: Layer ‘lstm_cell’ expected 3 variables, but received 0 variables during loading. Expected: [‘bidirectional/forward_lstm/lstm_cell/kernel:0’, ‘bidirectional/forward_lstm/lstm_cell/recurrent_kernel:0’, ‘bidirectional/forward_lstm/lstm_cell/bias:0’]

local machine version:

Python version
3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)]
Version info.
sys.version_info(major=3, minor=11, micro=0, releaselevel=‘final’, serial=0)
TensorFlow version: 2.15.1
Keras version: 2.15.0

databricks:
Python version
3.11.0rc1 (main, Aug 12 2022, 10:02:14) [GCC 11.2.0]
Version info.
sys.version_info(major=3, minor=11, micro=0, releaselevel=‘candidate’, serial=1)
TensorFlow version: 2.15.1
Keras version: 2.15.0

I have used the most recent version, but faced the same issue, I read somewhere that the issue could be avoided by using earlier tensorflow and keras version, which I did as indicated above. However, I am still facing the same issue.

Thanks for the assistance.

Hi @Kamal_Mokhtar, I have tried to save and load the bi-directional LSTM model. I have saved the model using model.save with .keras format and loaded the save model using tf.keras.models.load_model. I did not face any error while loading the model. And also make sure that you are using the same version of Tensorflow while saving and loading the model.

Please refer to this gist for working code example. Thank You.