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
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