Let's look at a more realistic case for using CNNs; we will use the Stanford Dogs versus Cats dataset. This dataset has 100+ images of dogs and cats.
Note
You can download this dataset (100 images each) from the following location: https://s3.amazonaws.com/neural-networking-book/ch04/dogs_vs_cats.tar.gz
- Import the relevant functions and Python classes:
import matplotlib.pyplot as plt import tensorflow as tf import pandas as pd import numpy as np from sklearn.metrics import confusion_matrix import time from datetime import timedelta import math import dataset import random
- We will define the parameters for the convolution layers. There are three convolution layers with the following parameters:
Layer number | Layer type | Number of filters/neurons |
1 | Convolution | 32 filters |
2 | Convolution | 32 filters |
3 | Convolution | 64 filters |
4 | Fully connected | 128 neurons |
The Network topolgy can be represented as shown in the following diagram:

The following code should be helpful for understanding...