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
[QUESTION] Use of clone_model() #454
Comments
Hi @juliotorrest ,
I want to ensure that every code example in the book is actually present in the corresponding notebook. It's a bit hard to do when I discuss several options, since the notebook then contains a mix of (often mutually incompatible) options. That's what's happening here. If I used Note that you only need to clone model A if you care about preserving its weights, and if you plan on fine-tuning that part of the final model. Plus, you could alternatively just reload model A later if you need it, using Anyway, assuming you do want to clone model A, then here's what the code would look like: model_A = keras.models.load_model("my_model_A.h5")
model_A_clone = keras.models.clone_model(model_A)
model_A_clone.set_weights(model_A.get_weights())
model_B_on_A = keras.models.Sequential(model_A_clone.layers[:-1]) # using the clone here
model_B_on_A.add(keras.layers.Dense(1, activation="sigmoid"))
[...] |
I added a comment in the notebook to clarify this, and I decided to just create |
Hello!
I am going through Chapter 11, "Reusing Pretrained Layers" section.
On cell 60, model_B_on_A is created from a pretrained model:
model_B_on_A = keras.models.Sequential(model_A.layers[:-1])
Then, on cell 61, the original model is cloned:
Finally, on cell 62 the model is compiled.
My question is, shouldn't model_B_on_A use 'model_A_clone' instead of 'model_A'? I guess it makes no difference, but it is just not 100% clear to me.
Thanks in advance!
The text was updated successfully, but these errors were encountered: