Use transfer learning with TensorFlow Hub pre-trained models for image classification. Freeze base layers, add classifier—achieve 90%+ accuracy with minimal training data vs 50% from scratch.
📚 This post is part of the "Machine Learning" series
What Is Transfer Learning (Feature Extraction) in TensorFlow?
Previously, I have described a simple Convolutional Neural Network,
which classified bird species with only 50% accuracy. The network architecture was similar to Tiny VGG
and had too many parameters leading to overfitting. Image classification is a complex
task. However, we can approach the problem while reusing state-of-the-art pre-trained models. Transfer learning is a machine learning technique that reuses patterns learned by a model on one dataset to improve performance on a different, related task. This way, we can efficiently apply
well-tested models, potentially leading to excellent performance.
In this post, we will focus on Feature Extraction,
one of the Transfer Learning techniques. I will build on the code and ideas previously
shared in my previous post “Convolutional Neural Networks for Image Classification.”
We will reuse previously created feature extraction models available at
the TensorFlow Hub for our task of bird species recognition
using image data from Kaggle. At the end of this post, we will see how this
approach will improve our bird species prediction model accuracy of 50% to over 90%.
Still in this guide
Downloading the 400 Bird Species Dataset from Kaggle
Visualizing the 400 Bird Species Image Data
Preprocessing and Augmenting Bird Images with ImageDataGenerator
Feature Extraction with Pre-trained TensorFlow Hub Models
Predicting Bird Species with the Trained Models
Saving and Loading a Trained Keras Model
Key Takeaways: Feature Extraction with TensorFlow Hub
References
You've hit a Deep Dive tutorial.
I spend dozens of hours researching, coding, and breaking things to write these guides. This content is free, but reserved for my subscriber community. Drop your email below to unlock this guide (and all past/future deep dives):
Full content temporarily unavailable — refresh in a moment
You're in
I'll send weekly notes on AI tools, Python, and what I'm actually building. Check your inbox for Set a password to unlock articles — the form does not log you in.
New subscribers get an inbox mail: Set a password to unlock articles. The form does not log you in — use the same email afterwards.
References
About Elena
Elena, a PhD in Computer Science, simplifies AI concepts and helps you use machine learning.
Citation
Elena Daehnhardt. (2022) 'TensorFlow: Transfer Learning (Feature Extraction) in Image Classification', daehnhardt.com, 03 March 2022. Available at: https://daehnhardt.com/blog/2022/03/03/tensorflow-transfer-learning-feature-extraction-image-classification-pre-trained-models-python-code/
Want the Fantastic AI 2026 toolkit and the Python virtual environments cheat sheet in your inbox?
Fantastic AI: The 2026 ToolkitPython Virtual EnvironmentsPython Errors & Logging
+4more free gifts
You're in
I'll send weekly notes on AI tools, Python, and what I'm actually building. Check your inbox for Set a password to unlock articles — the form does not log you in.