Keras: weighted binary crossentropy

后端 未结 6 567
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-31 08:39

I tried to implement a weighted binary crossentropy with Keras, but I am not sure if the code is correct. The training output seems to be a bit confusing. After a few epochs I j

6条回答
  •  鱼传尺愫
    2021-01-31 09:35

    In the case where you need to have a weighted validation loss with different weights than of the training loss, you can use the parameter validation_data of tensorflow.keras.model.fit() by putting your validation dataset as a tuple of Numpy arrays containing your validation data, labels and a weight for each sample.

    Note that you will have to map each sample to its weight using this technique (here by class).

    Follow the link here : https://www.tensorflow.org/api_docs/python/tf/keras/Model#fit

    tensorflow documentation

提交回复
热议问题