issue of conversion
i had the same error!  

I found a soultion using the keras legacy optimizer like this : 

tf.keras.optimizers.legacy.SGD

python: 3.8.18
tensorflow: 2.13.0 Hi @snehajhaveri01,

Please fill the [template](https://github.com/tensorflow/tensorflow/issues/new?assignees=&labels=TFLiteConverter&projects=&template=tflite-converter-issue.md) and share the reproducible code.

Thank You > i had the same error!
> 
> I found a soultion using the keras legacy optimizer like this :
> 
> tf.keras.optimizers.legacy.SGD
> 
> python: 3.8.18 tensorflow: 2.13.0

i solved it the same way , thank you ! > 3.8.18



> > i had the same error!
> > I found a soultion using the keras legacy optimizer like this :
> > tf.keras.optimizers.legacy.SGD
> > python: 3.8.18 tensorflow: 2.13.0
> 
> i solved it the same way , thank you !
 
how'd you solve it? i could not maintain python version in colab. I tried it on my machine. I have .h5 model but it is not able to load and showing

```
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']
```

I tried making python version of 3.8.18 and when installed tensorflow==2.13.0. It caused some problems with numpy and when I resolved it. now it is still not resolving the issue.

@maximilianofried @snehajhaveri01  I get this identical problem when loading a kaggle model into colab. 
How can it be that code that works in Kaggle fails to run in Google Colab?
On kaggle I saved a model and verified that it can load correctly.
model2 = load_model('/kaggle/working/model2.keras')
This works correctly on Kaggle and I can print the model summary. 
I then uploaded the .keras file to Google Colab, ran the same line of code to load the model and I get errors. 

ValueError: Unrecognized keyword arguments: ['batch_shape']

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
[/usr/local/lib/python3.10/dist-packages/keras/src/engine/base_layer.py](https://localhost:8080/#) in from_config(cls, config)
    868             return cls(**config)
    869         except Exception as e:
--> 870             raise TypeError(
    871                 f"Error when deserializing class '{cls.__name__}' using "
    872                 f"config={config}.\n\nException encountered: {e}"

TypeError: Error when deserializing class 'InputLayer' using config={'batch_shape': [None, 224, 224, 3], 'dtype': 'float32', 'sparse': False, 'name': 'input_layer_7'}.

Exception encountered: Unrecognized keyword arguments: ['batch_shape'] > I get this identical problem when loading a kaggle model into colab. How can it be that code that works in Kaggle fails to run in Google Colab? On kaggle I saved a model and verified that it can load correctly. model2 = load_model('/kaggle/working/model2.keras') This works correctly on Kaggle and I can print the model summary. I then uploaded the .keras file to Google Colab, ran the same line of code to load the model and I get errors.
> 
> ValueError: Unrecognized keyword arguments: ['batch_shape']
> 
> During handling of the above exception, another exception occurred:
> 
> TypeError Traceback (most recent call last) [/usr/local/lib/python3.10/dist-packages/keras/src/engine/base_layer.py](https://localhost:8080/#) in from_config(cls, config) 868 return cls(**config) 869 except Exception as e: --> 870 raise TypeError( 871 f"Error when deserializing class '{cls.**name**}' using " 872 f"config={config}.\n\nException encountered: {e}"
> 
> TypeError: Error when deserializing class 'InputLayer' using config={'batch_shape': [None, 224, 224, 3], 'dtype': 'float32', 'sparse': False, 'name': 'input_layer_7'}.
> 
> Exception encountered: Unrecognized keyword arguments: ['batch_shape']

This thread is dead. Try opening a new issue.
Also, I don't really know but just to check, have you used `model.save()` to save your model or `model.export()`?
I used `model.export()` and it worked for me, when you save your model using `model.export()` it saves the model's assets, variables and other stuff which works with conversion (at least in my case it did).

After using `model.export('mymodel')` I used this code to convert:

```
import tensorflow as tf

converter = tf.lite.TFLiteConverter.from_saved_model("mymodel")
tflite_model = converter.convert()

with open("mymodel.tflite", "wb") as f:
   f.write(tflite_model)
``` I will try model.export later, maybe that will work. 
It is also possible the problem was connected to my loss function 
loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True)
I added a softmax activation to the model and changed the loss function to loss='categorical_crossentropy' 
After training in kaggle I saved only the weights, then created the model in code in colab and imported the weights. That model could then be converted to .tflite  > I will try model.export later, maybe that will work. It is also possible the problem was connected to my loss function loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True) I added a softmax activation to the model and changed the loss function to loss='categorical_crossentropy' After training in kaggle I saved only the weights, then created the model in code in colab and imported the weights. That model could then be converted to .tflite

You can use `softmax` with `SparseCategoricalCrossEntropy` it's how it is usually used.
Also one more thing `model.save()` is now considered **lagacy** so now we use `model.export()`. 
I hope your issue is resolved. Your tip about export is good. 
I tried this : 
save_name = '/kaggle/working/mymodelpath'
model.export(save_name) # this will create a folder /mymodelpath with some subfolders and files
converter = tf.lite.TFLiteConverter.from_saved_model(save_name) # this will load from the subfolder and print some info

That seemed to work well. 
Error : 
Traceback (most recent call last):
  File "C:\Users\jhave\AppData\Local\Programs\Python\Python310\lib\site-packages\keras\src\engine\base_layer.py", line 868, in from_config
    return cls(**config)
  File "C:\Users\jhave\AppData\Local\Programs\Python\Python310\lib\site-packages\keras\src\utils\traceback_utils.py", line 70, in error_handler
    raise e.with_traceback(filtered_tb) from None
  File "C:\Users\jhave\AppData\Local\Programs\Python\Python310\lib\site-packages\keras\src\engine\input_layer.py", line 153, in __init__
    raise ValueError(
ValueError: Unrecognized keyword arguments: ['batch_shape']

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\jhave\OneDrive\Documents\mood-shift\model.py", line 6, in <module>
    keras_model = tf.keras.models.load_model('mood-shift.keras')
  File "C:\Users\jhave\AppData\Local\Programs\Python\Python310\lib\site-packages\keras\src\saving\saving_api.py", line 254, in load_model
    return saving_lib.load_model(
  File "C:\Users\jhave\AppData\Local\Programs\Python\Python310\lib\site-packages\keras\src\saving\saving_lib.py", line 281, in load_model
    raise e
  File "C:\Users\jhave\AppData\Local\Programs\Python\Python310\lib\site-packages\keras\src\saving\saving_lib.py", line 246, in load_model
    model = deserialize_keras_object(
  File "C:\Users\jhave\AppData\Local\Programs\Python\Python310\lib\site-packages\keras\src\saving\serialization_lib.py", line 728, in deserialize_keras_object
    instance = cls.from_config(inner_config)
  File "C:\Users\jhave\AppData\Local\Programs\Python\Python310\lib\site-packages\keras\src\engine\sequential.py", line 466, in from_config
    layer = layer_module.deserialize(
  File "C:\Users\jhave\AppData\Local\Programs\Python\Python310\lib\site-packages\keras\src\layers\serialization.py", line 276, in deserialize
    return serialization_lib.deserialize_keras_object(
  File "C:\Users\jhave\AppData\Local\Programs\Python\Python310\lib\site-packages\keras\src\saving\serialization_lib.py", line 609, in deserialize_keras_object
    return deserialize_keras_object(
  File "C:\Users\jhave\AppData\Local\Programs\Python\Python310\lib\site-packages\keras\src\saving\serialization_lib.py", line 728, in deserialize_keras_object
    instance = cls.from_config(inner_config)
  File "C:\Users\jhave\AppData\Local\Programs\Python\Python310\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, 30], 'dtype': 'float32', 'sparse': False, 'name': 'input_layer'}.

Exception encountered: Unrecognized keyword arguments: ['batch_shape']