I have issues when trying to use a custom function to compile a lstm model in Keras.
I have defined a custom metric function called mean_p_e
and I want to use it in my model built in Keras.
My code is:
import keras.backend as K
def mean_p_e(y_true, y_pred):
return K.mean((y_true - y_pred)**2/y_true)
Then I build my model, stored in a json file:
"model": {
"loss": "mse",
"optimizer": "adam",
"save_dir": "saved_models",
"metric":"mean_p_e",
and I compile:
model.compile(loss=configs['model']['loss'], optimizer=configs['model']['optimizer'], metrics=['accuracy', configs['model']['metric']])
And I get the Following error:
ValueError: Unknown metric function:mean_p_e
What do I need to change to make it works?