Image Classification with Convolutional Neural Networks

Day 2: Importing the necessary libraries

We will create a CNN that will be able to classify an image of fashion items such as coats, trousers, sandals into one of 10 predefined categories.


Make sure that you have installed tensorflow.

Open a new Python project, click copy text button and paste the contents into the first frame.

Run the code in the first frame.

This code imports libraries from Python.


Add a new frame, click copy text button and paste the contents into this frame.

Run the code in the first two frames.

This code gets the fashion file and splits the data into training and test sets.

Here is the output from script 2.

x_train shape: (60000, 28, 28, 1)
60000 train samples
10000 test samples

As you can see, the datast contains 60,000 images and the test group contains 10,000 of those images The images and labels are imported here.

The Fashion MNIST dataset is a large freely available database of fashion images that is commonly used for training and testing various machine learning systems. Fashion-MNIST was intended to serve as a replacement for the original MNIST database for benchmarking machine learning algorithms, as it shares the same image size, data format and the structure of training and testing splits.1

Let's peek inside the dataset. We can visualize some of the items with matplotlib.


Add a new frame, click copy text button and paste the contents into this frame.

Run the code in the first three frames.

This code gets shows images from the test set.

Here is the output from script 2.



These images are 28 by 28 pixels and in greyscale.