Building Your First CNN
Note
For this chapter, we are going to still use Keras on top of TensorFlow as the backend, as mentioned in Chapter 2, Introduction to Computer Vision of this book. Also, we will still use Google Colab to train our network.
Keras is a very good library for implementing convolutional layers, as it abstracts the user so that layers do not have to be implemented by hand.
In Chapter 2, Introduction to Computer Vision, we imported the Dense, Dropout, and BatchNormalization layers by using the keras.layers package, and to declare convolutional layers of two dimensions, we are going to use the same package:
from keras.layers import Conv2D
The Conv2D module is just like the other modules: you have to declare a sequential model, which was explained in Chapter 2, Introduction to Computer Vision of this book, and we also add Conv2D:
model = Sequential() model.add(Conv2D(32, kernel_size=(3, 3), padding='same', strides=(2,2), input_shape=input_shape))
For the first layer, the input shape...