Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unknown layer: KerasLayer when i try to load_model

When i try to save my model as hdf5

path = 'path.h5'
model.save(path)

then load the model again

my_reloaded_model = tf.keras.models.load_model(path)

I get the following error

ValueError: Unknown layer: KerasLayer

Any help ? I'm using

tensorflow version:  2.2.0  
keras version:  2.3.0-tf
like image 227
Assem Khaled Avatar asked Dec 11 '22 00:12

Assem Khaled


1 Answers

I just found a solution that worked for me

my_reloaded_model = tf.keras.models.load_model(
       (path),
       custom_objects={'KerasLayer':hub.KerasLayer}
)
like image 127
Assem Khaled Avatar answered Dec 29 '22 04:12

Assem Khaled