Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nan problem for LOG #17

Open
jganzabal opened this issue Oct 12, 2018 · 6 comments
Open

Nan problem for LOG #17

jganzabal opened this issue Oct 12, 2018 · 6 comments

Comments

@jganzabal
Copy link

I guess I would be safe to add epsilon to the log. Something like:
return -K.sum(alpha * K.pow(1. - pt_1, gamma) * K.log(K.epsilon()+pt_1))-K.sum((1-alpha) * K.pow( pt_0, gamma) * K.log(1. - pt_0 + K.epsilon()))

@jganzabal jganzabal changed the title Nan problema Nan problem for LOG Oct 12, 2018
@gulzainali98
Copy link

did you find the solution? i am getting nan loss

@jganzabal
Copy link
Author

@gulzainali98 adding K.epsilon() fixed Nan

@gulzainali98
Copy link

can this be used on simple classification? i.e i am using CelebA dataset. Image just have to be classified into 40 different classes there is no object detection.

@roywang2011
Copy link

can this be used on simple classification? i.e i am using CelebA dataset. Image just have to be classified into 40 different classes there is no object detection.

did you fixed your problem? I add K.epsilon() and still get nan

@Fellfalla
Copy link

Fellfalla commented Aug 4, 2019

@roywang2011 you need to make sure pt_1 does not become 1 and pt_0 does not become 0 when using gamma<1.0. Clip both with K.epsilon().

@abc1044
Copy link
Contributor

abc1044 commented Apr 23, 2021

I add K.epsilon(),and it works! 👍

abc1044 added a commit to abc1044/focal-loss-keras that referenced this issue Apr 23, 2021
According to mkocabas#17  , add K.epsilon() to fix nan problem for LOG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants