Saving and loading model via keras interface
majkee15 opened this issue · comments
Hi,
I have constructed a simple sequential model via TFL and although saving via model.save('file_name.h5') works fine, it is impossible to load with keras.models.load_model('h.h5') yielding "ValueError: Unknown layer: ParallelCombination".
example:
model = keras.models.Sequential()
model.add(combined_calibrators)
model.add(tf.keras.layers.RepeatVector(2))
model.add(lattice)
model.compile(loss=keras.losses.mean_squared_error,
optimizer=keras.optimizers.Adam(learning_rate=0.001))
model.save('h.h5')
m2 = keras.models.load_model('h.h5')
When you save/load as h5, you need to provide a custom objects mapping to include layers that are not part of the default keras lib. We provide a helper that includes all custom objects used in our canned models. See details here.
keras.models.load_model('h.h5', custom_objects=tfl.premade.get_custom_objects())