Hi everyone,

I encountered an issue when trying to load a Keras model saved as an .h5 file. Here's the setup:

  • Python version: 3.12
  • TensorFlow version: 2.18
  • Code:

```python from tensorflow.keras.models import load_model

# Trying to load a pre-saved model model = load_model('./resources/pd_voice_gru.h5') ```

  • Error message: ValueError: Unrecognized keyword arguments passed to GRU: {'time_major': False}

What I've tried: 1. Checked the TensorFlow and Keras versions compatibility. 2. Attempted to manually modify the .h5 file (unsuccessfully). 3. Tried to re-save the model in a different format but don't have the original training script.

Questions: 1. Why is time_major causing this error in TensorFlow 2.18? 2. Is there a way to ignore or bypass this parameter during model loading? 3. If the issue is due to version incompatibility, which TensorFlow version should I use?

Any help or suggestions would be greatly appreciated!

Thank you!

Comment From: fchollet

That option has been removed in Keras 3 (it was extremely niche). It looks like your saved model file makes a reference to the arg but doesn't use the option (time_major=False).

The solution is to remove the arg. If you have still access to the code, you can:

  1. Reload the model in Keras 2
  2. Save the weights only (model.save_weights(fname))
  3. Reload the model in Keras 3 (typically no code changes are necessary, but occasionally might be needed)
  4. Reload the weights file

Comment From: github-actions[bot]

This issue is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you.

Comment From: github-actions[bot]

This issue was closed because it has been inactive for 28 days. Please reopen if you'd like to work on this further.

Comment From: google-ml-butler[bot]

Are you satisfied with the resolution of your issue? Yes No