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

Unable to load weights from checkpoint in 05_transfer_learning_in_tensorflow_part_2_fine_tuning.ipynb #519

Open
piyushongithub opened this issue Feb 24, 2023 · 4 comments

Comments

@piyushongithub
Copy link

I ran the notebook "05_transfer_learning_in_tensorflow_part_2_fine_tuning.ipynb" on google colab but I got an error in "Model 4: Fine-tuning an existing model all of data" section. It seems like tensorflow is unable to load weights from checkpoint for model_2. . I am getting shape incompatible error. I have attached screenshot of the error below.

image

@JordanTheDodger
Copy link

JordanTheDodger commented Feb 24, 2023

@piyushongithub

Review your model.fit() code. It is a shape error caused due to not including ModelCheckpoint callback while refitting model 3(unfroze,fine-tune last 10). I encountered same error and attempted to resolve it by adding Model Checkpoint. I have also provided solution on Udemy as well

@piyushongithub
Copy link
Author

piyushongithub commented Feb 25, 2023

@JordanTheDodger But it would start fine-tuning from the stage model_3 was completed not from the stage of feature extractor. We want to fine tune from the stage of feature extractor (model_2 before fine tuning on 10% data).

@gonbaez
Copy link

gonbaez commented Apr 6, 2023

@piyushongithub I had the same issue. Apparently is because the order of the weights changes when saving the model with modified trainable attributes link.

I fixed it by saving the checkpoint as as h5 and setiing the base_modle layer to not trainable before loading the weights.
image

image

I hope this helps.

@mrdbourke
Copy link
Owner

Hi @piyushongithub,

This seems to be an issue with various versions of TensorFlow and the tf.keras.applications.efficientnet models.

Please see #544 for some potential fixes (namely installing TensorFlow 2.9.0 which seems to be the most stable version at the time of writing).

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

4 participants