Fine-Tuning EfficientNetB0 for Bird Species Image Classification
Transfer learning is a machine learning technique that reuses patterns learned by a pre-trained model on a new dataset and task. In my previous post “TensorFlow: Transfer Learning (Feature Extraction) in Image Classification”, I wrote about employing pre-trained models such as EfficientNet — trained on the [ImageNet][3] dataset and available in [the TensorFlow Hub][4] — for the task of bird species prediction. That earlier post covered the feature extraction approach. This post applies the fine-tuning approach I learned in the Udemy course on TensorFlow, describing transfer learning experiments that fine-tune a bird species prediction model. The code uses [the Keras EfficientNet API][6] for building EfficientNetB0-based models.
What Is Fine-Tuning in Transfer Learning?
Fine-tuning is a transfer learning method that unfreezes some layers of a pre-trained model and retrains them at a low learning rate to adapt learned features to a new dataset. In transfer learning, we reuse features learned on a different dataset for a different problem — useful when training data is limited and a state-of-the-art, well-tested model such as EfficientNet [5] is available. Transfer learning thus reuses features extracted from an existing model for predictions on a new dataset.
Figure 1 schematically shows the difference between feature extraction (see my post on feature extraction)
and fine-tuning in transfer learning. I have drawn it to outline the process of using
the trained on ImageNet model, in which layers are frozen during the feature extraction step.
After the model is converged with the use of the birds’ dataset, we unfreeze some unfrozen layers
while performing fine-tuning wherein the model is retrained with new data using the bird species dataset
[2].
Figure 1. Transfer Learning: feature extraction vs fine-tuning
The fine-tuning is done by unfreezing the frozen layers, partially or entirely, and retraining
the model with a meager learning rate. This way, we adapt the trained features to our new
(birds species) dataset while (potentially) achieving better prediction results.
Would fine-tuning be beneficial to our bird species prediction task? Let’s run some experiments
on feature extraction with fine-tuning and comparing their results with the feature extraction
without fine-tuning (the model described and evaluated in my previous post on feature extraction).
Retrieving and Preparing the 400 Bird Species Dataset
🔒 Subscribe to keep reading.
Model Creation: Four EfficientNetB0 Transfer Learning Variants
🔒 Subscribe to keep reading.
Saving Model Checkpoints with ModelCheckpoint Callbacks
🔒 Subscribe to keep reading.
1. Baseline EfficientNetB0 Feature Extraction Model
🔒 Subscribe to keep reading.
2. EfficientNetB0 Model with Data Augmentation
🔒 Subscribe to keep reading.
3. Fine-Tuning Model 2 by Unfreezing the Top 10 Layers
🔒 Subscribe to keep reading.
4. Final Model 4: No Augmentation, Top 100 Layers Unfrozen
🔒 Subscribe to keep reading.
Comparing the Four Transfer Learning Models by Accuracy
🔒 Subscribe to keep reading.
Bird Species Predictions with the Saved EfficientNetB0 Model
🔒 Subscribe to keep reading.
Conclusion: Fine-Tuning vs. Feature Extraction Results
🔒 Subscribe to keep reading.
References
🔒 Subscribe to keep reading.
Subscribe to unlock the full article ❤️
Log in to unlock
The form below signs you up for the newsletter. It does not log you into the app — log in afterwards (same email) to unlock this article and download your subscriber gifts. New subscribers get an inbox mail: Set a password to unlock articles.
Full content temporarily unavailable — refresh in a moment