Skip to content
Branch: master
Find file History

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.

Code for Chapter 3: Cats versus Dogs: Transfer Learning in 30 Lines with Keras

We use transfer learning to reuse a previously trained network on a new custom classification task to get near state-of-the-art accuracy in a matter of minutes. We then slice and dice the results to understand how well is it classifying. Along the way, we build a common machine learning pipeline, which is repurposed throughout the book.

On the note of transfer learning, we hear from Jeremy Howard, co-founder of on how hundreds of thousands of students use transfer learning to jumpstart their AI journey.

Read the chapter online here.


Go through the code in the following order:

  1. 1-building-a -custom-classifier-in-keras-with-transfer-learning.ipynb: We will build a custom classifier in Keras in 30 lines!
  2. 2-analyzing-the-results.ipynb: With our trained model, we can analyze how it's performing over the validation dataset. Beyond the simpler accuracy metrics, looking at the actual images of mispredictions should give an intuition on whether the example was truly hard or if our model is not sophisticated enough.


Download the Cats and Dogs dataset from Kaggle and place it in the data directory. You may have to create an account on Kaggle in order to download the data.

You can’t perform that action at this time.