More Transfer Learning Projects…

Image Recognition: Dogs vs Cats!

This tutorial builds a convolutional neural network from scratch, without transfer learning, to classify images as dog or cat, reaching 92% accuracy, and explains each step of the process. Using the Kaggle dogs vs cats dataset (about 25,000 images), it first cleans the data, with the reminder that you should never trust your data because data is always dirty, then loads the images with Keras, plots samples to check the labels, and uses ImageDataGenerator to hold out 20% of the images for validation.

The network is a simple stack of convolutional and pooling layers with a large dropout rate, refined through many experiments: adding layers and features until training accuracy neared 100%, then raising the dropout rate gradually from 0.4 to 0.9 to fight overfitting. For the optimizer, Adam and RMSProp often left the network stuck at 50% training accuracy, plain SGD learned but slowly, and AdaMax, a variant of Adam, worked well. Without augmentation the network starts overfitting around epoch 6 and reaches about 87% validation accuracy; with data augmentation training takes longer, overfitting drops sharply and accuracy reaches 92%. Finally it tries the pre-trained ResNet50 on a few images: it recognizes dogs (often down to the breed) but struggles with some cat photos, which leads to the next article on transfer learning.

The Arabic article is a translation of an English tutorial. Read the original: Image Recognition: Dogs vs Cats! (92%) (The Data Frog).

Leave a comment

Your email address will not be published. Required fields are marked *