0
$\begingroup$

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].

$\endgroup$
6
  • $\begingroup$ Just curious - what is your prior distribution (P(0) = 1-P(1)) ? $\endgroup$ Aug 3 '20 at 20:54
  • $\begingroup$ Yes P(0) = 1- P(1) $\endgroup$
    – Siddhi
    Aug 3 '20 at 21:00
  • $\begingroup$ 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. $\endgroup$ Aug 3 '20 at 21:20
  • $\begingroup$ I don't exact numbers but it is not balanced for sure, not 0.5 for sure. $\endgroup$
    – Siddhi
    Aug 3 '20 at 21:22
  • $\begingroup$ @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. $\endgroup$
    – Siddhi
    Aug 3 '20 at 22:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.