utkd / gans

Various GANs for playing around
35 stars 23 forks source link

It cannot generate the images as you did when I reran it #5

Closed WinterIsSunny closed 4 years ago

WinterIsSunny commented 5 years ago

I just ran this code on my gpu but did not get the similar images. actually the generated images are like random noise. And I also tried it on other dataset, but the accuracy of discriminator is always close to 0. I guess it is because of mode collapse, but you have used experience replay. I'm really confused now.

abhiishekpal commented 5 years ago

@WinterIsSunny did it finally work for you? Getting some random noisy output in image.

jinglin80 commented 5 years ago

The same. Run the code and the generated images are like random noise.

utkd commented 5 years ago

There could be multiple things going wrong. Can you give any additional information? What do the losses look like, how many times did you try to run (sometimes it might get stuck in a bad minima), etc?

jinglin80 commented 5 years ago

My loss is almost zero. Should the loss be defined differently?

On Thu, Jul 18, 2019 at 4:26 AM Utkarsh Desai notifications@github.com wrote:

There could be multiple things going wrong. Can you give any additional information? What do the losses look like, how many times did you try to run (sometimes it might get stuck in a bad minima), etc?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/utkd/gans/issues/5?email_source=notifications&email_token=AJL4ETY24NPAWGKPG22H4Q3QAASMDA5CNFSM4GHVGIQKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2HXJTY#issuecomment-512718031, or mute the thread https://github.com/notifications/unsubscribe-auth/AJL4ET57FYAN4A6B6WWIYHTQAASMDANCNFSM4GHVGIQA .

JohnTailor commented 4 years ago

Same here. Images look like random noise. It might have to do with Keras 2 API, it seems that there is no training going on since epochs run much to fast.

RafaelOO commented 4 years ago

I got the same problem. Has anybody found a solution? I do think it has something to do with the keras 2 API. I have checked other models and the same happened.

utkd commented 4 years ago

I no longer maintain this work, but since multiple people have commented, I decided to have a look. I do not have the exact setup anymore, so I loaded up the DCGAN notebook in Google Colab, downgraded the tensorflow version for compatibility and after running for 30 epochs, this is the output:

image

Although the images are blurry, you can still tell they are somewhat like cars and not at all random noise. Can you provide more details on what you are running and how? I can try to narrow down the problem.

RafaelOO commented 4 years ago

Thank you very much for your answer.

I am also running i t in Google Colab. Instead of downgrading it to 1.15, I modified the imports to run it in tensorflow 2.1. You can see the notebook here: https://drive.google.com/file/d/1RrbPntBjwtmGZ2XkYhDful2I8KGBlsW5/view?usp=sharing

This is an extract of the final output.

Epoch: 1, Generator Loss: 0.0009380715021817013, Discriminator Loss: [0.00207118 0. ] image

Epoch: 2, Generator Loss: 6.536680608114693e-06, Discriminator Loss: [0.00105942 0. ] image [...] Epoch: 15, Generator Loss: 5.7696864306926727e-05, Discriminator Loss: [0.00096073 0. ] image image

utkd commented 4 years ago

I tried to run the CGAN notebook and I did get a similar result. I was not able to spend a lot of time to fix this, but it looks like playing with the number of times the generator is trained vs number of time the discriminator is trained has a somewhat positive effect on the samples - even though they are still blurry, but definitely not noisy like above.

For example, train the discriminator once for every N times the generator is trained. You can do this for the generator as well, but it's usually not done. Can you try that out and see if it helps? N is usually in the range 2-5

utkd commented 4 years ago

Finally was able to fix the issue - was due to the misplaced 'break' in the experience replay code. I've removed it and ran the notebook on Colab. (Some other minor changes - removed an additional Conv layer in the generator, Train on only 50% of the CIFAR data to speed things up) The new notebook is now pushed to git.

I'm sorry it took me so long to fix this, but I've been busy with a lot of things at work. Hope you guys are looking at newer and better GANs by now.