Loading model with custom loss + keras

后端 未结 2 1711
情话喂你
情话喂你 2020-11-29 05:38

In Keras, if you need to have a custom loss with additional parameters, we can use it like mentioned on https://datascience.stackexchange.com/questions/25029/custom-loss-fun

2条回答
  •  暖寄归人
    2020-11-29 06:06

    Yes, there is! custom_objects expects the exact function that you used as loss function (the inner one in your case):

    model = load_model(modelFile, custom_objects={ 'loss': penalized_loss(noise) })
    

    Unfortunately keras won't store in the model the value of noise, so you need to feed it to the load_model function manually.

提交回复
热议问题