Reputation: 983
I define a custom loss function as follows:
weight_for_hierarchical_error = K.variable(np.ones(16))
def mse_weighted(y_true, y_pred):
return K.mean(weight_for_hierarchical_error * K.square(y_pred - y_true), axis=-1)
When I save the model in a hdf5 file and then try to load it with load_model
, I got following error information:
ValueError: Unknown loss function:mse_weighted
Does anyone know how to fix this problem?
Thanks!
Upvotes: 4
Views: 3814
Reputation: 983
This is solved here by passing a custom dictionary object to load_model
:
https://github.com/fchollet/keras/issues/5916 https://github.com/fchollet/keras/issues/3977
Upvotes: 6