CNNs for the Fashion MNIST

Can machines recognize tops from trousers?

Image for post
Image for post
The first 20 photos and labels of the Fashion MNIST testing set.

Why use a convolutional neural network?

Image for post
Image for post
It’s clearly a tree. Photo by Johann Siemens from Unsplash.

CNNs for feature recognition

Image for post
Image for post
The model sees the vamp on the left side, the sole in a diagonal, and the heel on the right side.
Image for post
Image for post
The model looks in the same places for the same features, but it won’t find what it’s looking for.
Image for post
Image for post
The model recognizes the vamp, the sole, and the heel, despite the mixed up order.

How does the CNN work?

Image for post
Image for post
This convolution operation has a filter of 3 by 3 with stride length 2 and uses “same” padding. Source.
Image for post
Image for post
For a more comprehensive view of CNNs, you can also read this article.

Building the model

model = models.Sequential()
model.add(layers.Conv2D(32, (3, 3), padding='same', activation='relu', input_shape=(28,28,1)))
model.add(layers.MaxPooling2D((2,2), strides = 2))
model.add(layers.Conv2D(64, (3,3), padding='same', activation = 'relu'))
model.add(layers.MaxPooling2D((2,2), strides = 2))
model.add(layers.Flatten())
model.add(layers.Dense(128, activation = 'relu'))
model.add(layers.Dense(10, activation = 'softmax'))
train_X = tf.reshape(train_X, [60000, 28, 28, 1])
test_X = tf.reshape(test_X, [10000, 28, 28, 1])

Learning how tomorrow's technologies will transform today's future. Especially interested in artificial intelligence and climate solutions.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store