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

Error in loss function #18

Closed
ymzhang1919 opened this issue Jan 11, 2017 · 3 comments
Closed

Error in loss function #18

ymzhang1919 opened this issue Jan 11, 2017 · 3 comments

Comments

@ymzhang1919
Copy link

   epsilon = tf.constant(value=1e-4)     
   logits = logits + epsilon
   softmax = tf.nn.softmax(logits)

It should be
epsilon = tf.constant(value=1e-4)
softmax = tf.nn.softmax(logits) + epsilon

@MarvinTeichmann
Copy link
Owner

Why? The purpose of the epsilon is to avoid numerical instability.

@ymzhang1919
Copy link
Author

ymzhang1919 commented Jan 12, 2017

I understand the purpose, but I don't understand how it works. Logits can be big negative numbers. How can you improve the numerical stability of the softmax() operation by adding a small positive number to logits?

On the other hand, adding a small positive number to softmax makes the log() operation more robust.

If I am wrong, can you explain it in detail? Thx.

@MarvinTeichmann
Copy link
Owner

You are right, I have fixed it.

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

2 participants