title: How can I normalize my loss function in relation to the number of elements in a class in Tensorflow?
body: <p>In an image segmentation problem, we will usually get a background label that dominates the mask and the object(s) occupying only a small area in the mask. 
  As such, during training, I have observed that my neural network does very well in classifying the background label but really poor at classifying the objects. </p>
  
  <p>I am using the Tensorflow's tf.nn.sparse_softmax_cross_entropy_with_logits as my lost function. Maybe in relation to this problem, my loss value is also not decreasing/converging. </p>
  
  <p>I was told that maybe I should consider adding a weighting factor to my loss function so that the dominant class will have a small weight compared to other non-dominant class. Can anyone share some insights? </p>