Now, since I'm not sure about what are g, q, x an y in your function, I'll just create a basic example here without caring about what it means or whether it's an actual useful function:import keras.backend as Kdef customLoss(yTrue,yPred): return K.sum(K.log(yTrue) - K.log(yPred))可以在此处查看所有后端功能.All backend functions can be seen here.之后,使用该函数而不是常规函数编译您的模型:After that, compile your model using that function instead of a regular one:model.compile(loss=customLoss, optimizer = .....) 这篇关于Keras 中的自定义损失函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-27 20:36