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

Why my train loss equal to nan? #17

Open
bingoohe opened this issue Jun 9, 2019 · 2 comments
Open

Why my train loss equal to nan? #17

bingoohe opened this issue Jun 9, 2019 · 2 comments

Comments

@bingoohe
Copy link

bingoohe commented Jun 9, 2019

Hi,
When I run dssm_rnn.py, the train loss always shows nan. Change learning rate, no matter what.
I print out the variables in the model, and the variable embedding in the word_embeddings_layer shows nan for the first time.
How to deal with it. Thanks!

@InsaneLife
Copy link
Owner

loss = -tf.reduce_sum(tf.log(hit_prob))
should add a minimal number like
loss = -tf.reduce_sum(tf.log(hit_prob + 1e-8))

@bingoohe
Copy link
Author

The log function is a reason. There is also a case where I will get 0 when calculating the norm.

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