I'm working on with an imbalanced dataset in Keras, and would like to give a higher weight to the samples from my minority class. The fit()
function has a nice sample_weight
argument, however because of the size of my data I have to use fit_generator()
.
fit_generator()
has a class_weight
argument, which seems useful for this purpose and is already discussed in Another question. However, in this case the labels are not one-hot-encoded/categorical and I could not find whether using class_weight
also allows for categorical data.
Can use the class_weight
argument for one-hot-encoded/categorical labels and if so how? Or do I have to resort to a custom weighted loss function?
sample_weight
would indeed be a nice solution, having thefit_generator
function unfortunately does not provide this option. – DGIB Aug 21 '17 at 06:38train_on_batch
which hassample_weight
, instead offit_generator
. Refer this link from Keras for further details. – Janki Mehta Aug 21 '17 at 07:31