Dataset preparation
Our task is to build an image classifier that distinguishes between dogs and cats. We get some help from Kaggle, from which we can easily download the dataset: https://www.kaggle.com/c/dogs-vs-cats/data.
In this dataset, training set contains 20,000 labeled images, and the test and validation sets have 2,500 images.
To use the dataset, you must reshape each image to 227×227×3. In order to do this, you can use the Python code in prep_images.py
. Otherwise, you can use the trainDir.rar
and testDir.rar
files from the repository of this book. They contain 6,000 reshaped images of dogs and cats for training, and 100 reshaped images for testing.
The following fine-tuning implementation, described in the section below, is implemented in alexnet_finetune.py
, which is downloadable in the code repository of the book.