0
$\begingroup$

I have the following two cross-entropy loss functions: $$x - x z + \log(1 + \exp(-x))$$ and for $x<0$ $$-x z + \log(1 + \exp(x))$$

where, $z$ is a value between $[0,1]$ and $x$ is a logit. And, both of the above equations have range $[0, \infty]$ Now, the combined formula is $$\max(x, 0) - x z + \log(1 + \exp(-|x|))$$

However, I'm not quite sure about why there is an absolute value inside the exp.

The actual math is here from tensorflow.

$\endgroup$
1
$\begingroup$

Work it out. When $x>0$, $|x|=x$, you immediately recover the first formula. If $x<0$, then you get $|x|=-x$, giving:

$$0-xz+\log(1+\exp(x))$$

$\endgroup$
1
  • $\begingroup$ OO! that makes perfect sense. I was for some reason trying to get back the first equation by plugging in x < 0. $\endgroup$
    – Jonathan
    Aug 27 '18 at 22:06

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.