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
If you don't have enough time to retrain the model in the solution way of Matias Valdenegro. You can set the default value of pool_size in class MyMeanPooling like the following code. Note that the value of pool_size should be consistent with the value while training the model. Then you can load the model.
class MyMeanPooling(Layer):
def __init__(self, pool_size, axis=1, **kwargs):
self.supports_masking = True
self.pool_size = 2 # The value should be consistent with the value while training the model
self.axis = axis
self.y_shape = None
self.y_mask = None
super(MyMeanPooling, self).__init__(**kwargs)
ref: https://www.jianshu.com/p/e97112c34e43