Model Loading Error with Bi-directional LSTM layer
@nilesh-sengupta Please use the appropriate loading function based on the saving format. For example, tf.keras.models.load_model for HDF5 and tf.saved_model.load for SavedModel.
Thank you! @sushreebarsa The model is in .keras format, it is saved using model.save('model_name.keras'), loading it using tf.saved_model.load gives the following exception:
Traceback (most recent call last):
  File "/usr/local/bin/mldnn/dnn_1.6/predictor.py", line 26, in <module>
    model = tf.saved_model.load('deep_neural_network.keras')
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/model_training/lib/python3.11/site-packages/tensorflow/python/saved_model/load.py", line 912, in load
    result = load_partial(export_dir, None, tags, options)["root"]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/model_training/lib/python3.11/site-packages/tensorflow/python/saved_model/load.py", line 1016, in load_partial
    loader_impl.parse_saved_model_with_debug_info(export_dir))
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/model_training/lib/python3.11/site-packages/tensorflow/python/saved_model/loader_impl.py", line 59, in parse_saved_model_with_debug_info
    saved_model = parse_saved_model(export_dir)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/miniconda3/envs/model_training/lib/python3.11/site-packages/tensorflow/python/saved_model/loader_impl.py", line 119, in parse_saved_model
    raise IOError(
OSError: SavedModel file does not exist at: deep_neural_network.keras/{saved_model.pbtxt|saved_model.pb}


The previous error is encountered while using tf.keras.models.load_model
 @nilesh-sengupta 
Could you try to re-save your Keras model as a SavedModel:
```
tf.saved_model.save(model, 'path/to/save/model')  # Use a distinct path to avoid overwriting

```


Since your model is in the .keras format, please use  tf.keras.models.load_model to load it:
```
model = tf.saved_model.load('path/to/save/model')


```
This function is specifically designed to handle models saved in the Keras format.
Thank you! This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you. This issue was closed because it has been inactive for 7 days since being marked as stale. Please reopen if you'd like to work on this further. Are you satisfied with the resolution of your issue?
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=Yes&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/64391">Yes</a>
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=No&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/64391">No</a>

I trained a model using tf==2.16.1 and keras 3.0.5.
While loading the same model through the same tf and keras versions (.keras format), the following error is encountered
File "/root/miniconda3/envs/model_training/lib/python3.11/site-packages/keras/src/saving/saving_api.py", line 176, in load_model
  return saving_lib.load_model(
      ^^^^^^^^^^^^^^^^^^^^^^
 File "/root/miniconda3/envs/model_training/lib/python3.11/site-packages/keras/src/saving/saving_lib.py", line 192, in load_model
  _raise_loading_failure(error_msgs)
 File "/root/miniconda3/envs/model_training/lib/python3.11/site-packages/keras/src/saving/saving_lib.py", line 273, in _raise_loading_failure
  raise ValueError(msg)
ValueError: A total of 2 objects could not be loaded. Example error message for object <LSTMCell name=lstm_cell, built=True>:

Layer 'lstm_cell' expected 3 variables, but received 0 variables during loading. Expected: ['kernel', 'recurrent_kernel', 'bias']

List of objects that could not be loaded:
[<LSTMCell name=lstm_cell, built=True>, <LSTMCell name=lstm_cell, built=True>]


Investigation mostly suggests it might be a version compatibility issue train vs load, but since both of these are being done in the same conda env I do no think it might be the case.