I built a Keras model with a custom layers, and it was saved to a .h5
file by the callback ModelCheckPoint
.
When I tried to load this model after
Actually I don't think you can load this model.
The most likely issue is that you did not implement the get_config()
method in your layer. This method returns a dictionary of configuration values that should be saved:
def get_config(self):
config = {'pool_size': self.pool_size,
'axis': self.axis}
base_config = super(MyMeanPooling, self).get_config()
return dict(list(base_config.items()) + list(config.items()))
You have to retrain the model after adding this method to your layer, as the previously saved model does not have the configuration for this layer saved into it. This is why you cannot load it, it requires retraining after making this change.