We have reached the point where we can actually implement a fully functional CNN after looking at the individual pieces: understanding the convolution operation, understanding pooling, and understanding how to implement convolutional layers and pooling. Now we will be implementing the CNN architecture shown in Figure 12.3.
Implementation
We will be implementing the network in Figure 12.3 step by step, broken down into sub-sections.
Loading data
Let's load the CIFAR-10 dataset as follows:
from tensorflow.keras.datasets import cifar10
from tensorflow.keras.utils import to_categorical
import numpy as np
# The data, split between train and test sets:
(x_train, y_train), (x_test, y_test) = cifar10.load_data()
x_train = x_train.astype('float32') / 255.
x_test = x_test.astype('float32') / 255.
y_train = to_categorical(y_train, 10)
y_test = to_categorical(y_test, 10)
print('x_train shape:', x_train.shape)
print('x_test shape...