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

tf.sqrt in WGAN-GP gradient penalty formula throws NaNs #68

Open
Imperssonator opened this issue Mar 9, 2018 · 2 comments
Open

tf.sqrt in WGAN-GP gradient penalty formula throws NaNs #68

Imperssonator opened this issue Mar 9, 2018 · 2 comments

Comments

@Imperssonator
Copy link

I've found in training on my own image dataset that I get an InvalidArgumentError: Nan in summary histogram. This was caused by the following line:

slopes = tf.sqrt(tf.reduce_sum(tf.square(grad_D_X_hat), reduction_indices=red_idx))

You'd think that the sum of squared values would never give anything less than 0, but apparently it does, because adding 1e-8 inside the sqrt() fixed the problem:

slopes = tf.sqrt( 1e-8 + tf.reduce_sum(tf.square(grad_D_X_hat), reduction_indices=red_idx))

@chunhanl
Copy link

I faced the same problem while training mnist with WGANGP, this solutions works fine for me.
Thanks~

@hujinsen
Copy link

hujinsen commented Jun 2, 2018

@Imperssonator faced the same problem too, that's a werid problem, thanks for saved my life!

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

3 participants