How to use class weights for hot encoded outputs with Keras

Viewed 1831

I am new to AI and I am using Keras and Tensorflow to train CNNs. My dataset is heavily unbalanced and I want to use class weights to counter that.

After a small search in the internet I found out that I can use scikit learn's class weight() and sample weight() to get the class weights and sample weights respectively and it can be passed to model.fit() in Keras. But I am unsure how to implement it programmatically for hot encoded outputs.

Can someone provide sample code explaining how to implement classweights for hot encoded outputs with Keras?

Thanks in advance

0 Answers
Related