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
Exception encountered: Unrecognized keyword arguments: ['batch_shape'] #66381
Comments
My thinking process onto this Error is probably due to multiple issues. I can lend a few ideas to the situation and anyone is free to correct me, if I'm wrong about it. First, I would check to see if the TenserFlow compiler is updated to the versions you're using. Maybe it could cause these issues. As it did suggest rebuild TenserFlow with appropriate compiler. Second, I would double check to see if the versions are even compatible. That could be causing issues. |
Hi @MuhammadBilal848 , Since TF2.16 uses Keras3 by default.In Keras3 saving to the TF SavedModel format via model.save() is no longer supported in Keras 3. Please refer to migration guide for some more details. |
So I trained another just to check and used and the folder is saved with assets , variables , pb file and fingerprint: I load the model using It worked. @SuryanarayanaY Thank you 🖤 |
Also could you tell me how can I convert the pd model to h5? I want to convert the model to tflite. Got:
|
|
Hi @MuhammadBilal848 , Thanks for confirmation and happy that it worked. Could you please mark this issue as closed. Thanks! |
I tried this on tf version 2.16.1 & 2.13.0 on python 3.10 and 3.8 respectively. My model is not that big it is under an MB, but this should not cause problem.
CODE:
import tensorflow as tf
h5_model = tf.keras.models.load_model('helfen_1.h5')
converter = tf.lite.TFLiteConverter.from_keras_model(h5_model)
tflite_model = converter.convert()
with open('converted_model.tflite', 'wb') as f:
f.write(tflite_model)
ERROR:
2024-04-24 23:00:17.022540: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: SSE SSE2 SSE3 SSE4.1 SSE4.2 AVX AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
Traceback (most recent call last):
File "t.py", line 3, in
h5_model = tf.keras.models.load_model('helfen_1.h5')
File "f:\Projects\Conv\convert\lib\site-packages\keras\src\saving\saving_api.py", line 238, in load_model
return legacy_sm_saving_lib.load_model(
File "f:\Projects\Conv\convert\lib\site-packages\keras\src\utils\traceback_utils.py", line 70, in error_handler
raise e.with_traceback(filtered_tb) from None
File "f:\Projects\Conv\convert\lib\site-packages\keras\src\engine\base_layer.py", line 870, in from_config
raise TypeError(
TypeError: Error when deserializing class 'InputLayer' using config={'batch_shape': [None, 50], 'dtype': 'float32', 'sparse': False, 'name': 'input_layer_10'}.
Exception encountered: Unrecognized keyword arguments: ['batch_shape']
The text was updated successfully, but these errors were encountered: