CNN: “Convolutional Neural Network”

A CNN uses multiple convolutions to complete its calculations. A convolution refers to the mathematical combination of two functions to produce an additional third function. This technique is used commonly in image classification problems.

Model Architecture

The overall model architecture looks like this:

Untitled

As can be seen, the original input goes through several convolutional layers, and then the output layer calculates the probability for the classification. Although convolutions can be difficult to understand, one simple way to understand what they do is they extract specific features from the image. For example, the first convolution may find the upper edges in the image, and the second convolution may find the bottom edges in the image. This information is then combined together to get an overall understanding of the image.

In our class, we made a CNN model together, which looks like this:

# Set the CNN Model

model = Sequential() # Allows us to make multiple layers

model.add(Conv2D(filters = 32, kernel_size = (5,5), padding="Same", activation="relu", input_shape = (28,28,1)))
model.add(Conv2D(filters=32, kernel_size = (5,5), padding="Same", activation="relu"))
model.add(MaxPool2D(pool_size=(2,2)))
model.add(Dropout(0.25))

model.add(Conv2D(filters = 64, kernel_size = (3,3), padding="Same", activation="relu"))
model.add(Conv2D(filters=64, kernel_size = (3,3), padding="Same", activation="relu"))
model.add(MaxPool2D(pool_size=(2,2)))
model.add(Dropout(0.25))

model.add(Flatten()) # Flatten the matrix, making it 1D
model.add(Dense(256, activation="relu"))
model.add(Dropout(0.5))
model.add(Dense(10, activation="softmax"))

The model we made together in class can make predictions such as what kind of flower is in the image.