jacobgil / keras-dcgan

Keras implementation of Deep Convolutional Generative Adversarial Networks
973 stars 413 forks source link

The code does not inhibit the learning process of the discriminator #10

Open fabbrimatteo opened 7 years ago

fabbrimatteo commented 7 years ago

The line discriminator.trainable = False does not stop the discriminator from learning. Replace that types of line with a call at the following function:

def make_trainable(net, val):
     net.trainable = val
     for l in net.layers:
         l.trainable = val
jacobgil commented 7 years ago

Thanks for the issue. It seems that .trainable = False freezes the entire model. Also discussed here: https://github.com/fchollet/keras/issues/4510 Can you please elaborate why do you think it should be set for each layer separately?

li-js commented 7 years ago

After setting the flag, do we need to re-compile the model before the parameters can be frozen? Here is a quotation from https://keras.io/getting-started/faq/

How can I "freeze" Keras layers?

Additionally, you can set the trainable property of a layer to True or False after instantiation. For this to take effect, you will need to call compile() on your model after modifying the trainable property
fabbrimatteo commented 7 years ago

@jacobgil i am confused by the fact that if you run:

model.summary()

before and after the command .trainable=False you can see that the number of trainable parameters does not change.