rajathkmp / DCGAN

Implementation of Deep Convolutional Generative Adversarial Networks on MNIST database in Keras
39 stars 12 forks source link

Generator compile #3

Open a2tm7a opened 6 years ago

a2tm7a commented 6 years ago

@rajathkmp Could you please tell why did you compiled Generator model in line 85 generator.compile(loss='binary_crossentropy', optimizer=adam, metrics=['accuracy'])

As while training we require and train only discriminator and dcgan as per line 132 and 135 discriminatorLoss = discriminator.train_on_batch(trainBatch, trainLabels) dcganLoss = dcgan.train_on_batch(noisePredictBatch, dcganLabels)

rajathkmp commented 6 years ago

@amitmanchanda1995 I was predicting the output after each epoch, so I had compiled it, it is not necessary if you are not interested in seeing the generator output after each iter

a2tm7a commented 6 years ago

But .predict works without compiling the model. You only need forward propagation and no backward propagation so why do you need to compile with a specified loss function?

rajathkmp commented 6 years ago

@amitmanchanda1995 Ahh, I remember now, check line 151. I could have simply reduced the lr of dcgan, but I have done it separately, to call the optimiser function I needed to compile it. You could also change line 150 and 151 with just dcgan.optimizer.lr, the output will be the same.