keras-dcgan icon indicating copy to clipboard operation
keras-dcgan copied to clipboard

The code does not inhibit the learning process of the discriminator

Open fabbrimatteo opened this issue 8 years ago • 3 comments

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

fabbrimatteo avatar Jan 25 '17 11:01 fabbrimatteo

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?

jacobgil avatar Jan 25 '17 20:01 jacobgil

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

li-js avatar Mar 22 '17 14:03 li-js

@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.

fabbrimatteo avatar Mar 22 '17 15:03 fabbrimatteo