BCELoss() how log compute log(0)

When I use the BCELoss(output, target), I found the output should be x>=0 && x <=1 ,but I don’t understand when the output = 1 or 0, how does log function compute?? (no error when the output is 0 or 1)

thanks!

I solved it.
In the source code,this line ,use the trick log(x + EPS) which results in that x can be 0 #define EPS 1e-12

3 Likes