‫OK, so now let's start building our first CNN model.
‫We will be using the same data that we use for classification problem in ANN
‫The task is to identify the fashion article name depending on their images.
‫We have 10 categories of different objects.
‫We have T-shirts, trousers, pullovers.
‫And for all of these articles we have, they are 28 by 28 pixel gray scale images.
‫We have already created a neural network model for this classification problem.
‫Now we are going to add convolutional layer with over and then more than.
‫So let's just start by importing some of the important libraries.
‫We are importing numpy, pandas
‫And matplot
‫Then we are also importing tensflow and keras.
‫Then, as I have told you earlier, we will be using fashion amnest data.
‫This data is available in keras datasets.
‫For more information, you can click on this link.
‫Here we have around 60000 images as our training data and another 10000 images as of our test data.
‫We have 10 different categories.
‫All these categories are labeled from zero to nine.
‫And this is the syntax
‫We are going to use to import fashion amnest data.
‫We have already done this in our ANN tutorial.
‫So I'm not going to spend our time on this.
‫So we're importing our data and do X train full, Y train full X test and Y test variables.
‫Let's just run this now since we have labels for all these articles.
‫We are going to create a list with their description so that we can refer this list whenever we get
‫a class label.
‫So let's create a class name list also.
‫Now we have to do data reshaping this donly change we are going to do in preprocessing of convolutional
‫neural network as compared to.
‫ANN
‫If you remember for ann we converted our 2d images into a single one dimensional array
‫Using flattern function.
‫But for CNN, we need a three dimensional array as input.
‫We need height, width.
‫And also another dimension.
‫For channels.
‫Currently, we have our X data in the form of this 2D images.
‫There is no another dimension for channels since these are simple grayscale images.
‫But by default for CNN layers, we need a 3 dimensional images.
‫So we are going to reshape our x train data and we are going to add another dimension to our data.
‫So earlier we were using 28 by 28 pixel images.
‫Now we are re shaping it into 28 into 28
‫Into 1, one it stands for Channel.
‫And again, we have 60000 images in our training dataset and 10000 images in our test dataset.
‫So before doing this reshape the shape of our x train full
‫Dataset was 60000, cross 28, cross 28, now for Convolutional Neural Network.
‫We are adding another dimension for channel as well.
‫So we are just adding another dimension to make it four dimensional.
‫Just on this now we have reshaped our data.
‫The next step is to normalize the data.
‫So all our pixel values are between 0 to 255.
‫So we are just going to divide our entire dataset by 255.
‫In that way, all our values will lie between zero and one.
‫We already did the similar thing for our ANN model as well.
‫So I'm not going to spend much time here.
‫Similarly, we are going to split our dataset into train and validation sets.
‫We are keeping 55000 images for our training dataset rest of 5000 images for our validation
‫dataset.
‫So let's, just run this as well.
‫So first, 5000 are going into validation and from 5000 to 60000 are going into training dataset
‫Now, let's set the seed for our tensor flow and numpy so that we get the same result every time
‫we run this code.