title: How to weight classes using fit_generator() in Keras?
body: <p>I am trying to use keras to fit a CNN model to classify images. The data set has much more images form certain classes, so its unbalanced. </p>
  
  <p>I read different thing on how to weight the loss to account for this in Keras, e.g.: 
  <a href="https://datascience.stackexchange.com/questions/13490/how-to-set-class-weights-for-imbalanced-classes-in-keras">https://datascience.stackexchange.com/questions/13490/how-to-set-class-weights-for-imbalanced-classes-in-keras</a>, which is nicely explained. But, its always explaining for the <strong>fit</strong>() function, not the <strong>fit_generator</strong>() one. </p>
  
  <p>Indeed, in the fit_generator() function we dont have the '<strong>class_weights</strong>' parameter, but instead we have '<strong>weighted_metrics</strong>', which I dont understand its description: "weighted_metrics: List of metrics to be evaluated and weighted by sample_weight or class_weight during training and testing."</p>
  
  <p>How can I pass from 'class_weights' to 'weighted_metrics'? Would any one have a simple example?</p>