Keras-GAN icon indicating copy to clipboard operation
Keras-GAN copied to clipboard

Gradient Penalty Loss: Not working with tf2

Open pabloi09 opened this issue 4 years ago • 4 comments

Good morning, The approach of the gradient_penalty_loss in the wgan_gp is not working with tf2. K.gradients returns [None]. You guys can find the issue here: https://colab.research.google.com/drive/11dcMKoiCigTnEn7QvmjqLNrJdmFztByT I have been reading some posts and it seems like there is no solution yet. Is there anyone that has already implemented this loss successfully with tf2? Thank you very much

pabloi09 avatar Apr 06 '20 10:04 pabloi09

Good morning, The approach of the gradient_penalty_loss in the wgan_gp is not working with tf2. K.gradients returns [None]. You guys can find the issue here: https://colab.research.google.com/drive/11dcMKoiCigTnEn7QvmjqLNrJdmFztByT I have been reading some posts and it seems like there is no solution yet. Is there anyone that has already implemented this loss successfully with tf2? Thank you very much

Maybe we can use tf.keras.backend.function to solve the problem. I write a sample version of WGAN-GP Here. It's tested on the newest tf.keras.

cckuailong avatar Apr 14 '20 08:04 cckuailong

Maybe we can use tf.keras.backend.function to solve the problem. I write a sample version of WGAN-GP Here. It's tested on the newest tf.keras.

Hello!

Your solution seems pretty smart. I didn't get to that and I ended doing the models extending tf.keras.Model and using GradientTape. This seems to be the standard now with tf2. The example I followed can be found Here

pabloi09 avatar Apr 14 '20 08:04 pabloi09

Maybe we can use tf.keras.backend.function to solve the problem. I write a sample version of WGAN-GP Here. It's tested on the newest tf.keras.

Hello!

Your solution seems pretty smart. I didn't get to that and I ended doing the models extending tf.keras.Model and using GradientTape. This seems to be the standard now with tf2. The example I followed can be found Here

Nice job! I think Keras will add the GradientTape soonly.

cckuailong avatar Apr 14 '20 09:04 cckuailong

can anyone write it with GradientTape?

Shuhain1994 avatar Nov 12 '20 15:11 Shuhain1994