Reputation: 1716
I am loading the keras saved model and getting the error.
new_model=load_model("my_model.h5")
new_model.summary()
Error
Traceback (most recent call last):
File "C:\Users\admin\Desktop\phd python projects\tensorflow_img_class\src\tensorflow ui.py", line 43, in <module>
new_model=load_model("my_model.h5")#, custom_objects = custom_objects)
File "C:\Python37\lib\site-packages\keras\engine\saving.py", line 419, in load_model
model = _deserialize_model(f, custom_objects, compile)
File "C:\Python37\lib\site-packages\keras\engine\saving.py", line 225, in _deserialize_model
model = model_from_config(model_config, custom_objects=custom_objects)
File "C:\Python37\lib\site-packages\keras\engine\saving.py", line 458, in model_from_config
return deserialize(config, custom_objects=custom_objects)
File "C:\Python37\lib\site-packages\keras\layers\__init__.py", line 55, in deserialize
printable_module_name='layer')
File "C:\Python37\lib\site-packages\keras\utils\generic_utils.py", line 145, in deserialize_keras_object
list(custom_objects.items())))
File "C:\Python37\lib\site-packages\keras\engine\sequential.py", line 300, in from_config
custom_objects=custom_objects)
File "C:\Python37\lib\site-packages\keras\layers\__init__.py", line 55, in deserialize
printable_module_name='layer')
File "C:\Python37\lib\site-packages\keras\utils\generic_utils.py", line 145, in deserialize_keras_object
list(custom_objects.items())))
File "C:\Python37\lib\site-packages\keras\layers\core.py", line 764, in from_config
return cls(**config)
File "C:\Python37\lib\site-packages\keras\legacy\interfaces.py", line 91, in wrapper
return func(*args, **kwargs)
File "C:\Python37\lib\site-packages\keras\layers\core.py", line 626, in __init__
super(Lambda, self).__init__(**kwargs)
File "C:\Python37\lib\site-packages\keras\engine\base_layer.py", line 128, in __init__
raise TypeError('Keyword argument not understood:', kwarg)
TypeError: ('Keyword argument not understood:', 'module')
I have already checked the Keras version that I have used to save the model and my current Keras on computer. Both are same and are Keras 2.2.4
When I am tried to load model by
model= tf.keras.models.load_model(
"saved_models/",
custom_objects=None,
compile=True)
I am getting permission denied error as following:
OSError: Unable to open file (unable to open file: name = 'saved_models/', errno = 13, error message = 'Permission denied', flags = 0, o_flags = 0)
I am not able to resolve this issue and would appreciate some help
Upvotes: 1
Views: 6005
Reputation: 56367
You didn't build the model using Keras 2.2.4, you built it using tf.keras
, and now you are loading it with keras
. Both modules are not actually compatible and this i why you get an error.
The simple solution is to never mix keras
with tf.keras
.
Upvotes: 4