Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unrecognized keyword arguments passed to GRU: {'time_major': False} using TensorFlow 2.18 and Python 3.12 #20750

Open
HkThinker opened this issue Jan 11, 2025 · 1 comment
Assignees
Labels
stat:awaiting response from contributor type:support User is asking for help / asking an implementation question. Stackoverflow would be better suited.

Comments

@HkThinker
Copy link

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:

    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!

@fchollet
Copy link
Collaborator

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

@dhantule dhantule added type:support User is asking for help / asking an implementation question. Stackoverflow would be better suited. stat:awaiting response from contributor labels Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stat:awaiting response from contributor type:support User is asking for help / asking an implementation question. Stackoverflow would be better suited.
Projects
None yet
Development

No branches or pull requests

4 participants