title: Keras - class_weight vs sample_weights in the fit_generator
body: <p>In Keras (using TensorFlow as a backend) I am building a model which is working with a huge dataset that is having highly imbalanced classes (labels). To be able to run the training process, I created a generator which feeds chunks of data to the <code>fit_generator</code>.</p>
  
  <p>According to the documentation for the <a href="https://keras.io/models/sequential/#fit_generator" rel="noreferrer">fit_generator</a>, the output of the generator can either be the tuple <code>(inputs, targets)</code> or the tuple <code>(inputs, targets, sample_weights)</code>. Having that in mind, here are a few questions:</p>
  
  <ol>
  <li>My understanding is that 
  the <code>class_weight</code> regards the weights of all classes for the entire dataset whereas
  the <code>sample_weights</code> regards the weights of all classes for each individual chunk
  created by the generator. Is that correct? If not, can someone elaborate on the matter?</li>
  <li>Is it necessary to give both the <code>class_weight</code> to the <code>fit_generator</code> and then the <code>sample_weights</code> as an output for each chunk? If yes, then why? If not then which one is better to give?</li>
  <li>If I should give the <code>sample_weights</code> for each chunk, how do I map the weights if some of the classes are missing from a specific chunk? Let me give an example. In my overall dataset, I have 7 possible classes (labels). Because these classes are highly imbalanced, when I create smaller chunks of data as an output from the <code>fit_generator</code>, some of the classes are missing from the specific chunk. How should I create the <code>sample_weights</code> for these chunks?</li>
  </ol>