1 00:00:05,480 --> 00:00:13,160 Now, let's create the structure of our first artificial neural network model before starting. 2 00:00:13,340 --> 00:00:18,950 Let's just set random seed 242 using these glues statements. 3 00:00:20,120 --> 00:00:24,460 Random seed is used to replicate the same desert every time. 4 00:00:25,430 --> 00:00:32,900 You can use any number instead of 42 if you use that number in future when you are running the same 5 00:00:32,900 --> 00:00:33,260 code. 6 00:00:33,620 --> 00:00:38,210 You will get the same output as we have discussed in the theory. 7 00:00:38,330 --> 00:00:45,680 There are multiple occasions where what neural network generates random number, such as assigning the 8 00:00:45,680 --> 00:00:53,660 initial weights using random seed will help you to reproduce the same result. 9 00:00:53,870 --> 00:00:59,240 Using the same initial weight every time just on this. 10 00:01:01,940 --> 00:01:09,080 So for the weight problem, we have observations in the form of 28 and 220 pixels. 11 00:01:10,250 --> 00:01:12,960 Observations are in the form of two B three. 12 00:01:14,150 --> 00:01:18,440 And as an output, we want ten categories. 13 00:01:19,460 --> 00:01:21,710 These categories are exclusive. 14 00:01:22,970 --> 00:01:29,870 That means a single image can either be a t shirt ordered top or a boot. 15 00:01:33,460 --> 00:01:35,140 This is what we are planning to do. 16 00:01:37,450 --> 00:01:44,710 We are first converting a word to be observations and do a flight when the observations. 17 00:01:45,640 --> 00:01:49,390 So insert over to be array of 28 and 228 pixel. 18 00:01:49,780 --> 00:01:54,100 We want 784 pixel in our input layer. 19 00:01:55,390 --> 00:01:59,020 Then we are going to create two hidden layers. 20 00:02:00,430 --> 00:02:08,950 The activation function, which we are going to use for hidden layers, will be value as discussed in 21 00:02:08,950 --> 00:02:09,930 the theory lecture. 22 00:02:10,120 --> 00:02:13,780 We always prefer RELU for classification models. 23 00:02:15,670 --> 00:02:20,020 And in the output since this 10 categories are exclusive. 24 00:02:20,720 --> 00:02:23,740 And and this is a classification model. 25 00:02:23,860 --> 00:02:26,480 We will be using softmax activation. 26 00:02:28,720 --> 00:02:32,830 We have already discussed this activation types in order to be reelected. 27 00:02:33,100 --> 00:02:35,620 That's why we are not going to discuss it here. 28 00:02:38,020 --> 00:02:43,510 Now let's start creating this neural network using sequential IPS of data. 29 00:02:46,270 --> 00:02:48,940 First, we will need to create and model object. 30 00:02:50,110 --> 00:02:52,600 So our object variable name is model. 31 00:02:53,200 --> 00:02:57,280 And we are just creating it using this function. 32 00:02:57,360 --> 00:02:59,620 Keita's dot models dot sequential. 33 00:03:01,640 --> 00:03:05,390 In this sequential object, we can add different layers. 34 00:03:05,930 --> 00:03:08,030 We will start with our input layer. 35 00:03:08,540 --> 00:03:12,200 We'll move on to then layer one, then to head on layer two. 36 00:03:13,280 --> 00:03:15,170 And then to the output layer. 37 00:03:17,240 --> 00:03:22,730 So first, for the input layer, we can write like this model dot egg. 38 00:03:23,390 --> 00:03:25,460 And then guide us dot layers. 39 00:03:26,570 --> 00:03:34,820 And then since we want to convert this to be array of 28 into 28 pixels to, say, 184 pixel in a single 40 00:03:34,820 --> 00:03:37,010 Larry, we are using flatten. 41 00:03:39,680 --> 00:03:48,200 And then we need to provide the input shape of over X variables, since about X variable is a boody 42 00:03:48,200 --> 00:03:50,300 at age 28 and 28 Viksten. 43 00:03:50,660 --> 00:03:57,380 We are using input chip equal to then we are providing a list of two variables that this friend dear 44 00:03:57,460 --> 00:03:58,550 call my 28. 45 00:04:01,950 --> 00:04:04,300 Then over second layer is the hidden layer. 46 00:04:06,330 --> 00:04:14,550 So in the next step, we are adding another layer that is model dot and then guitars, dot layer. 47 00:04:14,850 --> 00:04:17,630 And since this is a dense layer, will write dense. 48 00:04:18,990 --> 00:04:24,060 And here we need to mention the number of neurons we want in this layer. 49 00:04:26,100 --> 00:04:29,880 So in hidden layer one, we need 300 neurons. 50 00:04:30,240 --> 00:04:32,310 That's why we are writing 300. 51 00:04:32,970 --> 00:04:36,180 And then we want RELU activation function. 52 00:04:36,630 --> 00:04:42,840 That's why we are writing activation equal to Relu in the next step. 53 00:04:43,050 --> 00:04:44,760 We want another hidden layer. 54 00:04:45,750 --> 00:04:47,760 So we are following the same process. 55 00:04:48,480 --> 00:04:51,120 That is, we are writing more than not add. 56 00:04:52,020 --> 00:04:55,620 And in record we are writing Keita's dot layer dot bends. 57 00:04:56,400 --> 00:04:59,100 And in this layer we 100 hundred neurons. 58 00:05:00,300 --> 00:05:01,380 That's why we are writing. 59 00:05:01,410 --> 00:05:06,830 Hundred and then activation equal to Relu since this is also a hidden layer. 60 00:05:07,380 --> 00:05:12,810 We want activation function to be begin in the next output layer. 61 00:05:13,320 --> 00:05:15,420 We want 10 different categories. 62 00:05:15,630 --> 00:05:18,570 That's why we have to add 10 neurons. 63 00:05:18,600 --> 00:05:20,040 And to this layer. 64 00:05:21,360 --> 00:05:24,390 And since the classes are exclusive. 65 00:05:25,050 --> 00:05:28,170 That's why we have to use softmax activation. 66 00:05:30,540 --> 00:05:33,220 So we'll write model, not add. 67 00:05:33,930 --> 00:05:36,680 And then Keita's dot layers, dot bends. 68 00:05:37,200 --> 00:05:42,660 And then the number of neurons, which is span and activation, equate to softmax. 69 00:05:43,770 --> 00:05:52,890 I hope you remember Waterloo and Softmax are relu is zero for all the negative numbers and equate to 70 00:05:52,980 --> 00:05:55,800 the input for all the positive inputs. 71 00:05:57,460 --> 00:06:03,290 Various softmax equates the sum of all the class probability to one 72 00:06:05,920 --> 00:06:13,000 in case if you want any additional aid on land, you can always add additional layer between any of 73 00:06:13,000 --> 00:06:16,450 these layers in the later part of the course. 74 00:06:17,000 --> 00:06:21,910 We will see how to choose the number of neurons in each layer. 75 00:06:24,010 --> 00:06:29,240 Let's run this after creating this model structure. 76 00:06:30,790 --> 00:06:34,030 You can look at it using somebody's method. 77 00:06:34,330 --> 00:06:39,640 So if you write your object name, that is model and if you write dort somebody. 78 00:06:42,400 --> 00:06:47,990 The model, somebody's method displays all the modern layers, including eight layers. 79 00:06:48,010 --> 00:06:54,340 Names its output shape and the number of parameters. 80 00:06:56,680 --> 00:06:58,570 So these are the layer names. 81 00:06:59,230 --> 00:07:00,970 Second is the output shape. 82 00:07:01,840 --> 00:07:03,760 This the number of output. 83 00:07:04,180 --> 00:07:07,360 And this is the bed size of the input. 84 00:07:08,170 --> 00:07:10,190 Since we are passing all our data. 85 00:07:10,580 --> 00:07:12,230 That's why this is none. 86 00:07:12,640 --> 00:07:15,340 None means no limit on input data. 87 00:07:18,060 --> 00:07:29,100 And next is the number of Kreen label parameters, since our imports have 784 variables and we are passing 88 00:07:29,130 --> 00:07:32,220 each of these variables and to 300 different neurons. 89 00:07:32,790 --> 00:07:36,420 We have individual weights for each of these linkages. 90 00:07:37,050 --> 00:07:42,180 So total number of weights is 784 and two 300 plus. 91 00:07:42,240 --> 00:07:48,360 There are other 300 Biase variables that are associated with each of these neurons. 92 00:07:49,110 --> 00:07:54,390 So 784 and two 300 plus 300 will give you this number. 93 00:07:55,380 --> 00:08:01,500 Our neural network is trying to optimize this many parameters for this layer. 94 00:08:02,610 --> 00:08:05,990 Similarly, these are the trainable parameters for this layer. 95 00:08:06,720 --> 00:08:09,760 Again, this will be three hundred and 200. 96 00:08:10,710 --> 00:08:15,110 There are three hundred and two hundred linkages between these two layers. 97 00:08:15,480 --> 00:08:22,440 And each of that linkage will have associated weights and each of the neuron in this layer. 98 00:08:22,500 --> 00:08:26,190 That is, hundred neurons have hundred different Bias's values. 99 00:08:26,730 --> 00:08:29,760 So 300 and 200 plus hundred. 100 00:08:30,230 --> 00:08:35,130 So thirty thousand one hundred trainable parameters are associated with this layer. 101 00:08:36,240 --> 00:08:41,160 Similarly, 1010 trainable parameters are associated with this layer. 102 00:08:44,130 --> 00:08:48,960 So at the bottom, you get the summary of total number of trainable parameters. 103 00:08:49,320 --> 00:08:50,610 And this neural network. 104 00:08:50,880 --> 00:08:56,210 So our neural network will try to optimize this many parameters to get the best result. 105 00:08:59,350 --> 00:09:08,410 Now, if you want to look at the world now, if you want to look at our neural network, you can do 106 00:09:08,410 --> 00:09:09,680 that using Bidart. 107 00:09:10,420 --> 00:09:12,190 So you have to import Bidart. 108 00:09:12,760 --> 00:09:22,920 And if Bidart is not installed in your system, you can install it using PIP space, install space Bidart 109 00:09:23,230 --> 00:09:28,490 or KONDA Space, install space Bidart in your command prompt. 110 00:09:30,910 --> 00:09:39,250 So if you just redgate us not utilities, dot plot, underscore model and then give your object name. 111 00:09:40,780 --> 00:09:46,960 And if you run this, you will get the structure of fewer neural network. 112 00:09:47,470 --> 00:09:49,270 So here we have input layer. 113 00:09:49,900 --> 00:09:54,000 Then we have lightning that budy array and A one B array. 114 00:09:54,430 --> 00:09:56,360 So that's why we have a flatten layer. 115 00:09:57,520 --> 00:09:59,830 And then we have too dense who'd been led. 116 00:10:00,460 --> 00:10:04,750 And we have an output layer which is giving us the plus probabilities. 117 00:10:06,850 --> 00:10:12,970 So after creating the structure of your neural network, you can also visualize this, a structure using 118 00:10:12,970 --> 00:10:13,180 this. 119 00:10:13,180 --> 00:10:13,540 Come on. 120 00:10:16,300 --> 00:10:24,640 As I said earlier, our model is trying to optimize waits and biases that are represented by this number 121 00:10:24,940 --> 00:10:25,640 to get down. 122 00:10:27,990 --> 00:10:35,770 And if you remember interior lecture, we have discussed, death rates are assigned randomly for initialization 123 00:10:38,050 --> 00:10:41,650 to get the information of those rates and biases. 124 00:10:42,340 --> 00:10:49,810 There is a get underscored wait method that you can use to get information of those words and biases. 125 00:10:52,420 --> 00:10:54,700 So I can write my object name. 126 00:10:54,730 --> 00:10:59,920 That is mortal and then the layer number for the second layer. 127 00:11:00,010 --> 00:11:01,140 I can write layers. 128 00:11:01,750 --> 00:11:06,580 And then one since the location of object two is one. 129 00:11:07,150 --> 00:11:09,390 And then I can use get three. 130 00:11:09,400 --> 00:11:10,150 It's my turn. 131 00:11:12,210 --> 00:11:16,270 I'm sorting this information into two new variables, weights and biases. 132 00:11:16,930 --> 00:11:25,960 So if I just output the weights, you can see this are the randomly generated weights. 133 00:11:28,090 --> 00:11:36,070 Are 784 and do 300 such weights in this layer. 134 00:11:37,630 --> 00:11:40,960 So if you just view the shape, you can see that. 135 00:11:43,240 --> 00:11:52,580 There are 784 rows and 300 columns, and there were weeks these all weights are randomly assigned for 136 00:11:52,580 --> 00:11:53,510 an installation. 137 00:11:54,740 --> 00:12:02,450 Similarly, we can also look at the bias as Bias's values biases are initialized as zero. 138 00:12:02,870 --> 00:12:08,530 And if you just check the shape of biases, this should be 300. 139 00:12:14,370 --> 00:12:19,920 You can see that there are 300 Bias's in the next video. 140 00:12:20,040 --> 00:12:23,100 We will combine and train our model. 141 00:12:23,750 --> 00:12:24,110 Thank you.