I'm currently working on using tensorflow to adress a multi-class segmentation problem on a SegNet Architecture
My classes are heavily unbalanced and thus I need to integrate the median frequency balancing (using weights on classes on loss calculation). I use the following tip (based on this post) to apply Softmax. I need help to extend it in order to add the weights, I'm not sure how to do it. Current implementation:
reshaped_logits = tf.reshape(logits, [-1, nClass])
reshaped_labels = tf.reshape(labels, [-1])
loss = tf.nn.sparse_softmax_cross_entropy_with_logits(reshaped_logits, reshaped_labels)
My idea would be:
- To split the logits tensor in nClass tensor,
- Apply the softmax on each independently,
- Weight them with median frequency balancing
- Finally, summing the weighted losses.
Would that be the right approach?
Thanks