How to implement my own weighted loss function in Keras?

mariOn report abuse

Hi, forum. I would like to know how to add custom weights for the loss function in a binary or multiclass classifier in Keras. I am using binarycrossentropy or sparsecategorical_crossentropy, based on my model. And I want to be able to choose what weight to give incorrect predictions for each class.

Answers

CarlosCV report abuse

Basically, you can't change only weights of built-in Keras loss function. But you can create your own fully custom loss instead! Check this links: https://stackoverflow.com/questions/45961428/make-a-custom-loss-function-in-keras https://stackoverflow.com/questions/43818584/custom-loss-function-in-keras?rq=1

I hope these links will help you to go through that

Add Answer

Need support?

Just drop us an email to ... Show more