简体   繁体   中英

generator in GAN model generate images of one digit only ( with MNIST Dataset )?

i am learning to code GAN model

the code link here

after 100 epochs when i run generator , it generate one digit only the digit is : "7"

why it generate one digit only , although i change the random numbers every time before i give it to generator and the result is 7 every time

i use this code to test generator

u=np.random.randn(0,100)
ph=tf.reshape(generator(u)[0],(28,28)).numpy()
plt.imshow(ph,cmap='gray')

it gives me every time images of the digit 7 :

在此处输入图片说明 在此处输入图片说明

am i make a mistake in code ?? or what ??

the generator and decremenator models here to download if you want to try them :)

Several things here:

  1. The discriminator is nowhere near powerful enough to keep up with the generator. You need atleast 4-5 conv layers.

  2. You haven't used any activations in the generator. Try adding ReLU() after every BarchNormalization()

  3. To improve performance, try adding one or two conv layers after every transpose conv layer in the generator.

@Susmit Argawal may give you some solution, you can try it. I will raise my idea to answer why it always generates seven.

You didn't do anything wrong, GANs is the fight between Generator(G) and Discriminator(D). Image it as the philosophical way, when you can fool somebody in some way, you will try to do the same thing next time. That problem appears in GANs too, when the G can "minimize" the loss, it will learn less from data, produce samples with less variation (nearly similar).

Some new GANs model tries to reduce this in multiple ways, for example, "minibatch standard deviation" in ProGans paper . There are several tips for training the GANs model, follow it will help you reduce a lot of time.

Training GANs and tuning its parameters are painful and need a little luck, so just try it as much as possible.

Good luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM