How to implement hinge loss only for positive class in Tensorflow? I have binary classification task so the output is one-hot encoding of the label. So given out (Tensor of shape (batch_size,2)) and target (Tensor of shape (batch_size,2)) how to compute hinge loss for only those entries (rows) in out which are [0,1].
Asked
Active
Viewed 68 times
0
-
Just curious - what is your prior distribution (P(0) = 1-P(1)) ? – Match Maker EE Aug 03 '20 at 20:54
-
Yes P(0) = 1- P(1) – Siddhi Aug 03 '20 at 21:00
-
but the numbers … 0.5/0.5 OR 0.1/0.9 or 0.01/0.99 ? I have a tip on training from unbalanced training sets. – Match Maker EE Aug 03 '20 at 21:20
-
I don't exact numbers but it is not balanced for sure, not 0.5 for sure. – Siddhi Aug 03 '20 at 21:22
-
@MatchMakerEE I think it would be easier to implement when we just had labels {-1,+1} but now we have either [1,0] or [0,1] so i don't know how to implement hinge loss in the first place. – Siddhi Aug 03 '20 at 22:11
-
You can take a look at: https://stats.stackexchange.com/questions/476911/how-are-artificially-balanced-datasets-corrected-for/476948#476948 for how to cope with unbalanced datasets. MLPs with sigmoid nodes approach the posterior class probabilities. Hence, you can use the correction formulas for unbalanced datasets for such MLPs. Which activation function does your NN use ? – Match Maker EE Aug 03 '20 at 23:03