Replies: 1 comment
-
That's amazing! My graduation project used the pretrained model weights of EfficientetNetB0 to train my model, but there were inexplicable errors that left me deeply troubled. Thank you very much for your solution! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The following note keeps track of some relatively minor changes in Notebook 05: Transfer Learning with TensorFlow Part 2: Fine-tuning to migitate a few issues.
The main one being:
tf.keras.applications.efficientnet
being notoriously buggy across TensorFlow versions.The following code fixes should fix all issues in Notebook 05 and has been test on TensorFlow versions 2.12.0 and 2.13.0
TODO
effnetb0
is noweffnetB0v2
Quick summary
EfficientNetB0
->EfficientNetV2B0
to fix Notebook 05:TypeError: Unable to serialize [2.0897 2.1129 2.1082] to JSON. Unrecognized type <class 'tensorflow.python.framework.ops.EagerTensor'>
(fix inside) #553 (if you are getting errors with EfficientNetB0, try using EfficientNetV2B0)model_2
creation to fix Notebook 05: load_weights results in "Incompatible tensor with shape (1280, 10)..." #544base_model
clearerQuick links:
EfficienetNetB0 -> EfficientNetV2B0
In versions of TensorFlow 2.10+, the
tf.keras.applications.efficientnet.EfficientNetB0
(EfficientNetB0
for short) module seemed to be plagued with errors.To fix this, all uses of
EfficientNetB0
have been replaced withtf.keras.applications.efficientnet_v2.EfficientNetV2B0
(EfficientNetV2B0
for short).New:
Old:
Why?
Mostly because I've found less bugs (alongside other students of the course, TK - Moophers GitHub).
Note: This doesn't necessarily mean
EfficientNetV2B0
is the best model for the job, it performs well on many computer vision tasks, however, it's only used as an example. Best to experiment with other model versions intf.keras.applications
to find the best model for your own problem.This takes care of the issue in #553.
Functionizing
model_2
creationBecause
model_2
is used several times throughout Notebook 05, I made a reference function to recreate it.That way we know whenever the function is called, we're getting a new instance of
model_2
(rather than potentially reusing an old one).This way, for experiment 3 and experiment 4, we can use a new instance of
model_2
, load the weights from experiment 2 and then fine-tune appropriately.This helps to fix the issue in #544 (though this issue is also related to EfficientNetB0 being notoriously buggy across TensorFlow versions).
Change
base_model
->model_2_base_model
Using the same
base_model
variable throughout the notebook got confusing.So I updated it to be
model_2_base_model
so we know which base it relates to.For example:
Beta Was this translation helpful? Give feedback.
All reactions