﻿1
00:00:00,820 --> 00:00:05,400
‫OK, so now let's start building our first CNN model.

2
00:00:07,170 --> 00:00:15,270
‫We will be using the same data that we use for classification problem in ANN

3
00:00:15,390 --> 00:00:20,970
‫The task is to identify the fashion article name depending on their images.

4
00:00:23,730 --> 00:00:26,700
‫We have 10 categories of different objects.

5
00:00:27,450 --> 00:00:30,060
‫We have T-shirts, trousers, pullovers.

6
00:00:31,020 --> 00:00:38,730
‫And for all of these articles we have, they are 28 by 28 pixel gray scale images.

7
00:00:41,190 --> 00:00:45,870
‫We have already created a neural network model for this classification problem.

8
00:00:47,520 --> 00:00:52,470
‫Now we are going to add convolutional layer with over and then more than.

9
00:00:54,580 --> 00:00:59,400
‫So let's just start by importing some of the important libraries.

10
00:00:59,640 --> 00:01:01,480
‫We are importing numpy, pandas

11
00:01:01,650 --> 00:01:02,490
‫And matplot

12
00:01:05,100 --> 00:01:08,580
‫Then we are also importing tensflow and keras.

13
00:01:11,260 --> 00:01:16,120
‫Then, as I have told you earlier, we will be using fashion amnest data.

14
00:01:17,800 --> 00:01:21,370
‫This data is available in keras datasets.

15
00:01:22,540 --> 00:01:25,120
‫For more information, you can click on this link.

16
00:01:26,170 --> 00:01:34,600
‫Here we have around 60000 images as our training data and another 10000 images as of our test data.

17
00:01:35,590 --> 00:01:37,480
‫We have 10 different categories.

18
00:01:38,020 --> 00:01:41,260
‫All these categories are labeled from zero to nine.

19
00:01:44,320 --> 00:01:45,950
‫And this is the syntax

20
00:01:46,300 --> 00:01:49,880
‫We are going to use to import fashion amnest data.

21
00:01:50,200 --> 00:01:53,770
‫We have already done this in our ANN tutorial.

22
00:01:54,010 --> 00:01:57,910
‫So I'm not going to spend our time on this.

23
00:02:01,320 --> 00:02:09,360
‫So we're importing our data and do X train full, Y train full X test and Y test variables.

24
00:02:10,350 --> 00:02:16,260
‫Let's just run this now since we have labels for all these articles.

25
00:02:16,830 --> 00:02:23,650
‫We are going to create a list with their description so that we can refer this list whenever we get

26
00:02:23,650 --> 00:02:24,750
‫a class label.

27
00:02:25,930 --> 00:02:28,990
‫So let's create a class name list also.

28
00:02:31,680 --> 00:02:39,870
‫Now we have to do data reshaping this donly change we are going to do in preprocessing of convolutional

29
00:02:39,930 --> 00:02:42,270
‫neural network as compared to.

30
00:02:42,420 --> 00:02:42,840
‫ANN

31
00:02:45,540 --> 00:02:52,860
‫If you remember for ann we converted our 2d images into a single one dimensional array

32
00:02:53,100 --> 00:02:54,420
‫Using flattern function.

33
00:02:55,470 --> 00:02:59,700
‫But for CNN, we need a three dimensional array as input.

34
00:03:00,900 --> 00:03:02,850
‫We need height, width.

35
00:03:03,810 --> 00:03:05,750
‫And also another dimension.

36
00:03:05,780 --> 00:03:06,720
‫For channels.

37
00:03:08,400 --> 00:03:12,720
‫Currently, we have our X data in the form of this 2D images.

38
00:03:12,900 --> 00:03:19,230
‫There is no another dimension for channels since these are simple grayscale images.

39
00:03:20,760 --> 00:03:25,440
‫But by default for CNN layers, we need a 3 dimensional images.

40
00:03:26,070 --> 00:03:33,630
‫So we are going to reshape our x train data and we are going to add another dimension to our data.

41
00:03:34,410 --> 00:03:39,030
‫So earlier we were using 28 by 28 pixel images.

42
00:03:39,720 --> 00:03:43,940
‫Now we are re shaping it into 28 into 28

43
00:03:43,980 --> 00:03:46,280
‫Into 1, one it stands for Channel.

44
00:03:47,850 --> 00:03:55,170
‫And again, we have 60000 images in our training dataset and 10000 images in our test dataset.

45
00:03:56,850 --> 00:04:02,400
‫So before doing this reshape the shape of our x train full

46
00:04:02,400 --> 00:04:09,930
‫Dataset was 60000, cross 28, cross 28, now for Convolutional Neural Network.

47
00:04:11,130 --> 00:04:14,040
‫We are adding another dimension for channel as well.

48
00:04:14,430 --> 00:04:20,070
‫So we are just adding another dimension to make it four dimensional.

49
00:04:21,420 --> 00:04:26,070
‫Just on this now we have reshaped our data.

50
00:04:26,700 --> 00:04:29,400
‫The next step is to normalize the data.

51
00:04:31,650 --> 00:04:36,690
‫So all our pixel values are between 0 to 255.

52
00:04:37,590 --> 00:04:42,090
‫So we are just going to divide our entire dataset by 255.

53
00:04:42,450 --> 00:04:45,980
‫In that way, all our values will lie between zero and one.

54
00:04:48,090 --> 00:04:52,560
‫We already did the similar thing for our ANN model as well.

55
00:04:52,950 --> 00:04:56,190
‫So I'm not going to spend much time here.

56
00:04:57,900 --> 00:05:03,240
‫Similarly, we are going to split our dataset into train and validation sets.

57
00:05:04,590 --> 00:05:13,200
‫We are keeping 55000 images for our training dataset rest of 5000 images for our validation

58
00:05:13,200 --> 00:05:13,700
‫dataset.

59
00:05:15,240 --> 00:05:17,880
‫So let's, just run this as well.

60
00:05:19,080 --> 00:05:27,750
‫So first, 5000 are going into validation and from 5000 to 60000 are going into training dataset

61
00:05:30,060 --> 00:05:39,540
‫Now, let's set the seed for our  tensor flow and numpy so that we get the same result every time

62
00:05:39,540 --> 00:05:40,410
‫we run this code.

