Convolutional network for image classification
Convolutional networks for classification are constructed from a sequence of convolutional layers (for image processing) and fully connected (Dense
) layers (for readout). In this exercise, you will construct a small convolutional network for classification of the data from the fashion dataset.
This exercise is part of the course
Image Modeling with Keras
Exercise instructions
- Add a
Conv2D
layer to construct the input layer of the network. Use a kernel size of 3 by 3. You can use theimg_rows
andimg_cols
objects available in your workspace to define theinput_shape
of this layer. - Add a
Flatten
layer to translate between the image processing and classification part of your network. - Add a
Dense
layer to classify the 3 different categories of clothing in the dataset.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Import the necessary components from Keras
from keras.models import Sequential
from keras.layers import Dense, Conv2D, Flatten
# Initialize the model object
model = Sequential()
# Add a convolutional layer
model.add(____(10, kernel_size=____, activation='relu',
input_shape=____))
# Flatten the output of the convolutional layer
model.add(____())
# Add an output layer for the 3 categories
model.add(____(____, activation='softmax'))