when i tried to load keras model, i encountered this weird error:
here is my code:
model = tf.keras.models.load_model('/kaggle/input/iyntmodel/vgg19.keras')
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
File /opt/conda/lib/python3.10/site-packages/keras/src/engine/base_layer.py:868, in Layer.from_config(cls, config)
867 try:
--> 868 return cls(**config)
869 except Exception as e:
File /opt/conda/lib/python3.10/site-packages/keras/src/utils/traceback_utils.py:70, in filter_traceback.<locals>.error_handler(*args, **kwargs)
68 # To get the full stack trace, call:
69 # `tf.debugging.disable_traceback_filtering()`
---> 70 raise e.with_traceback(filtered_tb) from None
71 finally:
File /opt/conda/lib/python3.10/site-packages/keras/src/engine/input_layer.py:153, in InputLayer.__init__(self, input_shape, batch_size, dtype, input_tensor, sparse, name, ragged, type_spec, **kwargs)
152 if kwargs:
--> 153 raise ValueError(
154 f"Unrecognized keyword arguments: {list(kwargs.keys())}"
155 )
157 if sparse and ragged:
ValueError: Unrecognized keyword arguments: ['batch_shape']
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
Cell In[13], line 1
----> 1 model = tf.keras.models.load_model('/kaggle/input/iyntmodel/vgg19.keras')
File /opt/conda/lib/python3.10/site-packages/keras/src/saving/saving_api.py:254, in load_model(filepath, custom_objects, compile, safe_mode, **kwargs)
249 if kwargs:
250 raise ValueError(
251 "The following argument(s) are not supported "
252 f"with the native Keras format: {list(kwargs.keys())}"
253 )
--> 254 return saving_lib.load_model(
255 filepath,
256 custom_objects=custom_objects,
257 compile=compile,
258 safe_mode=safe_mode,
259 )
261 # Legacy case.
262 return legacy_sm_saving_lib.load_model(
263 filepath, custom_objects=custom_objects, compile=compile, **kwargs
264 )
File /opt/conda/lib/python3.10/site-packages/keras/src/saving/saving_lib.py:281, in load_model(filepath, custom_objects, compile, safe_mode)
278 asset_store.close()
280 except Exception as e:
--> 281 raise e
282 else:
283 return model
File /opt/conda/lib/python3.10/site-packages/keras/src/saving/saving_lib.py:246, in load_model(filepath, custom_objects, compile, safe_mode)
244 # Construct the model from the configuration file in the archive.
245 with ObjectSharingScope():
--> 246 model = deserialize_keras_object(
247 config_dict, custom_objects, safe_mode=safe_mode
248 )
250 all_filenames = zf.namelist()
251 if _VARS_FNAME + ".h5" in all_filenames:
File /opt/conda/lib/python3.10/site-packages/keras/src/saving/serialization_lib.py:728, in deserialize_keras_object(config, custom_objects, safe_mode, **kwargs)
726 safe_mode_scope = SafeModeScope(safe_mode)
727 with custom_obj_scope, safe_mode_scope:
--> 728 instance = cls.from_config(inner_config)
729 build_config = config.get("build_config", None)
730 if build_config:
File /opt/conda/lib/python3.10/site-packages/keras/src/engine/sequential.py:466, in Sequential.from_config(cls, config, custom_objects)
464 for layer_config in layer_configs:
465 use_legacy_format = "module" not in layer_config
--> 466 layer = layer_module.deserialize(
467 layer_config,
468 custom_objects=custom_objects,
469 use_legacy_format=use_legacy_format,
470 )
471 model.add(layer)
473 if (
474 not model.inputs
475 and build_input_shape
476 and isinstance(build_input_shape, (tuple, list))
477 ):
File /opt/conda/lib/python3.10/site-packages/keras/src/layers/serialization.py:276, in deserialize(config, custom_objects, use_legacy_format)
268 if use_legacy_format:
269 return legacy_serialization.deserialize_keras_object(
270 config,
271 module_objects=LOCAL.ALL_OBJECTS,
272 custom_objects=custom_objects,
273 printable_module_name="layer",
274 )
--> 276 return serialization_lib.deserialize_keras_object(
277 config,
278 module_objects=LOCAL.ALL_OBJECTS,
279 custom_objects=custom_objects,
280 printable_module_name="layer",
281 )
File /opt/conda/lib/python3.10/site-packages/keras/src/saving/serialization_lib.py:609, in deserialize_keras_object(config, custom_objects, safe_mode, **kwargs)
602 if isinstance(module_objects[config], types.FunctionType):
603 return deserialize_keras_object(
604 serialize_with_public_fn(
605 module_objects[config], config, fn_module_name
606 ),
607 custom_objects=custom_objects,
608 )
--> 609 return deserialize_keras_object(
610 serialize_with_public_class(
611 module_objects[config], inner_config=inner_config
612 ),
613 custom_objects=custom_objects,
614 )
616 if isinstance(config, PLAIN_TYPES):
617 return config
File /opt/conda/lib/python3.10/site-packages/keras/src/saving/serialization_lib.py:728, in deserialize_keras_object(config, custom_objects, safe_mode, **kwargs)
726 safe_mode_scope = SafeModeScope(safe_mode)
727 with custom_obj_scope, safe_mode_scope:
--> 728 instance = cls.from_config(inner_config)
729 build_config = config.get("build_config", None)
730 if build_config:
File /opt/conda/lib/python3.10/site-packages/keras/src/engine/base_layer.py:870, in Layer.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}.nnException encountered: {e}"
873 )
TypeError: Error when deserializing class 'InputLayer' using config={'batch_shape': [None, 299, 299, 3], 'dtype': 'float32', 'sparse': False, 'name': 'input_layer_1'}.
Exception encountered: Unrecognized keyword arguments: ['batch_shape']