Elena' s AI Blog

TensorFlow: Transfer Learning (Feature Extraction) in Image Classification

03 Mar 2022 (updated: 19 Oct 2026) / 29 minutes to read

Elena Daehnhardt

Jasper AI-generated art, January 2023


TL;DR:
  • 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

Series: Machine Learning (Part 12 of 28)

Previous: Part 11 — TensorFlow: Convolutional Neural Networks for Image Classification

Next: Part 13 — TensorFlow: Transfer Learning (Fine-Tuning) in Image Classification

Where this fits:Neural networksTraining and fine-tuning Explore the AI Landscape →

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):

Already a subscriber? Use the magic link from your last newsletter, or reset your password.

New subscribers get an inbox mail: Set a password to unlock articles. The form does not log you in — use the same email afterwards.

desktop bg dark

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/
All Posts