Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why do you change d.trainable twice after d.compile during train? #19

Open
haozhi1817 opened this issue Jul 27, 2017 · 1 comment
Open

Comments

@haozhi1817
Copy link

haozhi1817 commented Jul 27, 2017

It seems you can only change one model's trainable before model.compile, if you compile one model, your change of trainable will not work. So, why do you change model.trainable twice during train :
x= np.concatenate((image_batch, generated_images))
y = [1] * BATCH_SIZE + [0] * BATCH_SIZE
d_loss = d.train_on_batch(X, y)
print("batch %d d_loss : %f" % (index, d_loss))
noise = np.random.uniform(-1, 1, (BATCH_SIZE, 100))
d.trainable = False #'here'
g_loss = d_on_g.train_on_batch(noise, [1] * BATCH_SIZE)
d.trainable = True #'here'
print("batch %d g_loss : %f" % (index, g_loss))

@haozhi1817 haozhi1817 changed the title Why you change d.trainable twice after d.compile during train? Why do you change d.trainable twice after d.compile during train? Jul 28, 2017
@germunwang
Copy link

I found the same problem, there're some unnecessary line to change trainable,
and it seems that you should recompile once you set trainable as True or False to freeze layers.

example:
https://keras.io/applications/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants