[00:00:00] So basically what is basically there are various variants of R and we will be only looking [00:00:28] at currently simple RNN okay so there is vanilla RNN also which you can try okay so currently [00:00:40] what we are doing here is importing IMDB dataset okay from tensorflow I think tensorflow you [00:00:49] guys all aware of tensorflow keras pytorch etc okay then we are importing a pre-processing [00:00:59] technique known as sequence why sequence because as the data is textual okay so that's why and [00:01:14] the data is of in sequences like you can say a sentence sentence is what a sequence of [00:01:21] words okay so that's why we are importing sequence okay then we will be importing the features [00:01:32] that way basically it is the vocabulary size what is the vocabulary size basically how [00:01:38] many words can be kept to reduce the dimensionality now I think you guys know what is the dimensionality [00:01:50] okay then what can be the maximum length of a review data okay got my point up to here [00:02:02] okay then there is nothing then splitting the data into training and testing sets one is uh x is the [00:02:17] uh or uh you can uh independent variable and y is the target variable okay for the same test data [00:02:29] okay x and y for this all splitting uh after splitting these things we are importing we are sorry loading [00:02:39] the data of IMDB with how number of words will be the maximum number of features basically this number of [00:02:49] of words are kept okay in during loading these this IMDB data any queries until here [00:03:09] yeah uh basically we will be uh uploading uh the things okay first uh the things when will be completed [00:03:24] and then we will be uploading and we'll be covering all the things like transformer and coda decoder okay [00:03:33] then comes the gpt basically it is the uh you can say uh application of uh transformer okay so basically [00:03:41] you will be uh seeing it analyzing it in an application oriented manner okay okay any questions [00:03:54] any other questions [00:03:55] any other questions [00:04:03] okay so uh uh now now moving forward okay [00:04:11] now uh anyone knows what is padding [00:04:15] in uh text data uh or image data everyone knows i i think i assume everyone knows what is padding [00:04:25] okay so we are doing nothing but in training data we are also uh using padding in which each review [00:04:37] is padded with maximum length of review suppose the review say length is only 400 so it will be padded with [00:04:46] 100 more uh words okay like to uh maximize the its length to 500 okay if the length length is 200 [00:04:55] then it will be padded then it will be padded with it will be padded with 300 [00:05:00] okay so so same is the case with test data okay here we also doing padding to keep the thing same [00:05:13] okay so any question in in this first cell [00:05:20] any question [00:05:25] okay okay okay so uh uh let me uh take the uh one example okay [00:05:44] for uh instance suppose our maximum length is 10 okay because i cannot write here in 500 [00:05:51] sick uh maximum length okay suppose our maximum length is 10 okay now i write a word wish okay [00:06:04] okay wish [00:06:09] you [00:06:12] good [00:06:17] morning okay so basically if i look here [00:06:21] uh how many uh how many uh you can say uh sequences are there [00:06:29] how many sequences suppose this is a sentence okay how many sequences are there [00:06:41] can anyone tell [00:06:42] okay okay so if i take about at a void level only void level so there are four sequences if i take [00:06:54] about a character level so there are one two three four space five then up to like more than [00:07:02] uh 15 [00:07:04] sequences okay so currently we're taking at the void level okay [00:07:08] okay okay now as i said let us suppose the maximum length is 10 for instance okay so currently we have [00:07:16] only uh four uh see uh four sequences okay so how the padding will work this is i am telling only [00:07:24] an application of word uh one technique i have taken a uh random sequence from the data itself [00:07:33] a wish wish okay and before also some good so how many uh six are there okay then you [00:07:45] seven [00:07:48] eight and here also [00:07:50] nine [00:07:56] and one more [00:07:57] 10 okay so this is a one technique now search it's by yourself that which technique it is okay [00:08:05] because i will not tell this what is the name of this technique okay so that's how padding works [00:08:11] basically we have to make the sequence up to 10 okay because the input will work like that okay [00:08:20] as we have defined that the maximum length of the data will be 10. got the point or any more questions [00:08:41] okay so so uh now moving forward so clear with the first cell how how the things are working here [00:08:54] the maximum length is 500 so we are filling it with uh the remaining uh uh sequences okay [00:09:01] now moving forward so now here we have uh a simple rnn model basically simple what simple means we have [00:09:13] only one embedding layer this is the embedding layer where uh the input dimensions are maximum number of [00:09:23] features basically this number of features okay and the output dimensions that we have defined is 32. [00:09:30] now can anyone tell how the dimension reduction will work from this 10 000 to 32 anyone knows mathematically [00:09:45] anyone knows [00:09:52] yeah this is a one technique okay so basically you you you can use [00:10:00] various techniques to reduce the dimensionality okay using pca or using psne etc okay [00:10:08] where so now moving forward where the input length is the maximum number of length that is 500 you can [00:10:14] directly here write 500 also but actually why we do not do so because if typo errors are there so from my [00:10:23] error i have written i have written 400 so error will come okay so that's why we define a variable and [00:10:29] directly refer to it that it is the maximum length of the uh input okay so now we have defined a simple rnn [00:10:39] with the of 32 units what is what is meant by units anyone knows what is meant by units [00:10:53] uh [00:10:56] and like yourkeeping [00:10:56] the uh [00:10:58] um [00:11:10] it is the number of neurons okay basically so basically we have the 32 number of neurons to [00:11:35] handle the dimension of 32 okay so this thing we basically try to keep these things in a simple [00:11:45] manner okay so that's why we have defined so each neuron will will keep one dimension okay so you [00:11:52] can correlate with it so at the output we get a one dimension output and we have then defined [00:12:00] activation function of sigmoid because it is a binary classification task so so got the point [00:12:08] that how the thing is working how how we have reduced the dimensions and then how the output [00:12:16] of dense is coming because every neuron is handling one one dimension at each time so [00:12:22] the output neuron will also handle the only one dimension and it can only give one output okay [00:12:29] there cannot be multiple outputs in machine learning this is a basic fundamental okay [00:12:35] so that's why we we have a one one output layer for the binary classification [00:12:43] okay so any questions in this cell [00:12:48] any questions [00:12:59] okay so so moving forward [00:13:10] so you can directly calculate here you can directly what we basically do we compile the model with [00:13:22] optimizer we can uh we will also change the loss we will also uh uh change the activation function okay we [00:13:32] will uh let us hit and try okay because uh currently what we are seeking though basically in deep learning [00:13:43] initially we do not know which uh uh optimizer or which activation function or which uh [00:13:51] uh loss function will be suitable for our data set okay i am talking about the suitability of uh model and the data okay [00:14:00] currently we have binary classification so we know that only two classes are there so it will be a sigmoid function [00:14:05] but what it will be the multiple classes okay what if the features are different okay [00:14:14] currently we have only uh two features that is the sentence and that is the uh second is the uh uh review [00:14:22] that it is a positive or the negative okay but what if there are multiple features okay [00:14:28] so how to handle that thing so we are going in a that that direction okay we will be look looking into [00:14:36] that that that how the performance of a model works if change if we change the optimizer function the [00:14:45] activation function and the uh different different uh parameters okay [00:14:54] so let us run this cell okay so in between if you guys have any more questions or so you can ask okay [00:15:06] now moving forward to tensorflow the second cell [00:15:30] now we will compile the model and we will run the uh we will train the model on only let us try to up [00:15:44] to three epochs so that we can note its value okay [00:15:48] so here you can also see we have splitted our data into validation also point two means what [00:16:07] 20 percent of the training data we have splitted for validation so suppose we have 100 percent of the [00:16:14] data data we have kept for uh we have first we separated our test data after that during the training uh [00:16:25] time we have also separated our validation uh data so that we can validate our training [00:16:35] that how it is performing so currently just note down that currently the training uh performance is 92.16 [00:16:44] okay and the validation is 80.48 okay now we will do some uh parameter tuning or uh normally we call it as [00:16:56] hyper parameter tuning okay so what can be the other sigma other uh activation functions [00:17:05] what can be the other activation functions [00:17:14] uh i am talking in a classification task only apart from sigmoid what can be the activation function [00:17:32] yeah we can use uh softmax as it is uh basically suit basically sigmoid is best suitable for binary [00:17:42] classification but for the main time we are using softmax [00:17:53] okay then what can be the optimizer [00:18:00] one is adam w then next [00:18:08] what can be the optimizer [00:18:12] what can be the optimizer [00:18:34] okay so i am just for the meantime i am taking about the item w okay [00:18:39] loss will be i am taking same as the binary cross entropy okay [00:18:52] yes we can use uh the softmax function in the intermediate layer but as we have only one layer [00:19:00] like the input is coming and the output is seeking though [00:19:03] okay okay if uh if uh if if we can increase the dimensions up to 64 like uh i will also do that [00:19:11] thing uh okay if the time uh the time [00:19:15] foundation is not there because we have also cover lstm and gru okay [00:19:21] then we can also try that like what we have to do we have to just copy these three lines okay then [00:19:28] simple rnn up to 64 neurons okay then dense up to two then there is one activation function [00:19:37] okay as the or you can say directly here then again simple rnn 32 okay [00:19:46] then at last the output layer will come with the dense function okay [00:19:51] okay got the point [00:19:59] any question [00:20:08] okay so now let us run the cell as we have changed the things [00:20:16] um [00:20:28] okay [00:20:30] uh [00:20:31] okay [00:20:32] uh [00:20:33] um [00:20:34] okay [00:20:34] oh [00:20:35] it's [00:20:36] okay [00:20:36] it's [00:20:38] So now here you can see that the accuracy has dipped to 50 and the validation has also [00:21:07] dipped to 49. [00:21:09] So you can see here that how optimality can be achieved with the suppose we have seen [00:21:19] this one first and then I will show you the previous one in the second show. [00:21:27] So what does it indicate that basically we have to test each and every parameter on [00:21:37] the optimizer thing, on the loss thing, on the activation function thing. [00:21:46] We have to try each and every function for our data. [00:21:59] Any more questions? [00:22:00] Okay. [00:22:01] So just let us try to make it between two layers. [00:22:18] Okay. [00:22:19] So here I will write also one thing I have to here add and I have to also return the sequences [00:22:40] of each embedding. [00:22:41] Return sequences will it be true. [00:22:47] Okay. [00:22:48] Then I will again add this simple RNN here. [00:23:05] Okay. [00:23:06] Of 32. [00:23:07] Okay. [00:23:08] Now let us try to run it with which function did we used before sigmoid. [00:23:26] Okay. [00:23:28] And here the Adam optimizer. [00:23:33] Okay. [00:23:40] So now let us try with two RNN layers. [00:23:44] Okay. [00:23:45] So let us see what happens. [00:23:52] Imagine. [00:23:56] Okay. [00:23:57] How do we make it? [00:23:58] Okay. [00:24:03] So let us try. [00:24:09] Okay. [00:24:18] Yeah. [00:24:19] Okay. [00:24:21] currently uh if if if anyone is looking closely [00:24:51] okay return sequences basically means basically what the previous neurons are basically [00:25:12] uh saving their uh values basically uh you have seen in machine learning or in the neural network [00:25:22] itself that uh just a minute let me take a new file you have seen that i am building a typical [00:25:40] neural network not a recurrent neural network okay we use it in all all uh places okay [00:25:48] suppose this is a neural network [00:25:53] okay and here and then here and this is the output then we have these interconnections [00:26:10] okay and then here it is one output okay what return sequences basically mean i will ask one question [00:26:36] from where this neuron is getting well the value its value [00:26:46] it is layer two okay from where this neuron is getting its value [00:27:06] okay from previously uh it is getting its value so which which uh data will return uh [00:27:26] its value to its neuron the previous layer as we are using sequences so that's why we use [00:27:33] uh you can also uh see it like return sequences to this neuron from the previous layer so that's why we [00:27:43] write return sequences equals to true so that we can get the data from the previous layer [00:27:51] now the same concept works in rnn okay this is a typical neural network architecture [00:27:57] here got the point now any questions apart from this this part after that i will ask one question [00:28:15] any question [00:28:16] okay okay so my question is this i have done a mistake intentionally in this line [00:28:32] what is it [00:28:32] return sequence is nothing but we are calling you can say the calling the data from the previous layer as [00:28:48] we have the dimension saved in the previous layer of rnn so we are just calling them in the current [00:28:54] layer okay from the input layer to the layer one [00:28:57] one [00:29:00] why it should two [00:29:10] yes the answer is correct this is actually two this will be actually two why because i have defined [00:29:17] the two layers so the two layers will be become as input for this output layer but i have defined [00:29:23] only one out one in out uh input layer for is it so this is wrong basically only this layer [00:29:32] will be again giving its output and this layer will be getting dropped okay this layer will will not [00:29:40] be connected with this output layer so here i will do the two okay now let us do one more thing as [00:29:50] there is uh one more question of activation functions okay let us define uh activation function uh here [00:30:01] uh activation equals we will be defining here [00:30:07] what i i will define here [00:30:12] let us try with tanh [00:30:13] what can from which uh what activation functions can we take here [00:30:24] let us go with tanh okay here also we will be going through tanh okay [00:30:32] okay this is fine so currently we have previously run all the cells so currently you can see here the [00:30:45] accuracy is 89 and here is also the 84 so just um keep them in mind okay now it will it can change okay [00:30:54] so let us see [00:31:01] why this thing can anyone tell [00:31:10] what is the issue [00:31:10] okay [00:31:20] again i have done this intentionally [00:31:23] you [00:31:40] Thank you. [00:32:22] What is the difference? [00:32:32] No. [00:32:32] Now, I just told you in the starting of the class that if we take two layers, we have [00:32:48] to increase our dimensions. [00:32:55] Have we increased? [00:32:56] First, if we are taking two and the output dimension is 32, what will be the output dimension [00:33:08] here as it is the input thing? [00:33:11] Will it not be 64? [00:33:16] Here we also. [00:33:20] Will it not be 64? [00:33:26] Okay. [00:33:27] And here also will it not be 64? [00:33:31] Okay. [00:33:32] Now, let us try. [00:33:38] Okay. [00:33:39] So, it has again gone into same error. [00:33:54] Why is it so? [00:33:56] Because as we have defined, basically what is happening here, as we have two classes and [00:34:01] the dimension is defined into 32 of the 32, you can say, okay, 32 cross dimensions. [00:34:12] Okay. [00:34:12] But what currently we are trying to do, the output we are trying to define the two, but [00:34:19] here also we are defining in 64, 64 and 64. [00:34:25] So, if we take 32, 32, 32 and 32 and it will take it as one. [00:34:31] Okay. [00:34:32] It will work. [00:34:33] Why? [00:34:34] Because the dimensions are same as we have only two classes. [00:34:40] Okay. [00:34:41] So, let us try to print our shape. [00:34:50] Okay. [00:34:57] X [00:35:04] shape. [00:35:05] Okay. [00:35:09] This is the shape. [00:35:12] Okay. [00:35:17] Now, you can also print for the Y train. [00:35:24] Okay. [00:35:24] In the same and in the same manner and for the same test manner, for the test case, you can [00:35:33] also do the same task. [00:35:36] Okay. [00:35:43] Got the point? [00:35:53] Now, I will add only one thing. [00:35:56] As we, uh, as we, uh, want the 32 dimension, the thing. [00:36:03] Okay. [00:36:05] What if I do? [00:36:07] If I add one more layer. [00:36:10] Dance off. [00:36:12] I only have to convert it 32. [00:36:15] What can we take the activation function? [00:36:20] As we have take the 10H. [00:36:22] Okay. [00:36:26] Should we take ReLU or Leaky ReLU? [00:36:33] Let us try with ReLU. [00:36:36] Okay. [00:36:37] So, here it is this. [00:36:43] So, we have run this cell. [00:36:45] Okay. [00:36:46] Let us try with this and this. [00:36:48] So, again. [00:36:51] Okay. [00:36:52] So, I think it will not work because as we have typically defined here with the 32 dimensions. [00:36:59] Okay. [00:37:00] So, we will try, uh, uh, after some time, uh, this thing. [00:37:04] Okay. [00:37:05] Let us move forward. [00:37:07] So, basically, just, uh, doing the control Z. [00:37:14] And this is the basic, this was the basic thing. [00:37:17] Okay. [00:37:22] So, now, basically, how, basically, you predict, uh, the test accuracy and the test loss. [00:37:28] Okay. [00:37:30] This is the key thing. [00:37:31] Okay. [00:37:44] So, just waiting for it to finish. [00:37:53] Yeah, I will explain that thing. [00:38:13] Okay. [00:38:14] I will just explain. [00:38:15] Just a minute. [00:38:17] Just see the plots and then I will explain what is the difference. [00:38:20] Okay. [00:38:23] Then, we will be covering. [00:38:25] So, basically, this is the training, uh, you can say plot. [00:38:29] This is the training accuracy and validation accuracy. [00:38:32] Okay. [00:38:33] And if you just, uh, you can say flip this plot, the accuracy plot, you, you can correlate with this. [00:38:41] That it is going in the loss. [00:38:43] Okay. [00:38:45] In the loss direction. [00:38:49] Okay. [00:38:50] Got till point here. [00:38:52] Got the point till here. [00:38:56] Then, we will talk about the target shape mismatch. [00:38:59] Okay. [00:39:00] When it happens and why, why it happens. [00:39:03] Okay. [00:39:03] Basically, why it happens. [00:39:05] So, basically, what is happening currently, uh, let us again open my paint. [00:39:29] Uh, yeah. [00:39:31] Okay. [00:39:35] We have an input sequence of currently 500, uh, sequences. [00:39:57] Okay. [00:39:57] As we have defined our 500 sequences. [00:40:01] Okay. [00:40:03] Now, what, uh, we are trying basically, to reduce them in the 32 dimensions. [00:40:14] Okay. [00:40:15] To reduce them in the 32 dimensions. [00:40:21] Okay. [00:40:22] And then, will be the, one output layer will contain the output with the dimensional, uh, [00:40:32] dimension of its output. [00:40:34] Okay. [00:40:35] Which will predict whether the, uh, review, uh, is positive or negative. [00:40:43] Got the things? [00:40:51] This is our default one. [00:40:53] What, uh, our, uh, current code is working on. [00:40:59] Okay. [00:41:00] Now, what we are trying to do for the shape of activation. [00:41:07] Okay. [00:41:07] Uh, so, uh, how activation is also working, uh, you guys know, uh, how activation works. [00:41:14] I think you, you know, how activation works. [00:41:24] Do you know, uh, how activation for works? [00:41:27] Okay. [00:41:37] So, basically, it is nothing but, it will calculate the probability, uh, basically, it [00:41:46] will calculate, uh, the things of activation, which, uh, neuron will get, of the layer will [00:41:51] get activated at that time or not. [00:41:53] Okay. [00:41:54] The same thing will, will go here. [00:41:56] Okay. [00:41:57] Now, basically, what we are trying to build, it to, is to convert it into something like [00:42:05] the same input 500, of 500 sequences. [00:42:11] Okay. [00:42:12] Then converting it into 64 dimensions. [00:42:20] Okay. [00:42:23] Then, again, a simple RNN layer will come of the same 64 dimensions. [00:42:31] Okay. [00:42:34] Then, it will be handled with the layer of 32 units neurons. [00:42:42] Okay. [00:42:44] So, for the, each dimension will handle, each two dimensions will be handled. [00:42:50] by one neuron. [00:42:51] So, that's why the dance will be called as two. [00:42:55] And, okay, which will be classified as, you can say here, the 32, because each layer [00:43:02] will be handled by the two. [00:43:03] So, two into 32 will be the 64. [00:43:05] We will be achieving the same dimension. [00:43:08] Okay. [00:43:09] And after that, we will be doing the same classification task. [00:43:14] Positive or negative. [00:43:20] Okay. [00:43:24] We are trying. [00:43:37] Okay. [00:43:38] So, this is a, basically, good question. [00:43:42] Why the output layer dimension is 1, 32? [00:43:46] Just multiply it. [00:43:48] How will it, how much it will be? [00:43:50] For the simple RNN model, for the basic RNN model, just multiply it. [00:44:00] Just, I will say the, do the back provocation. [00:44:04] 1 multiplied by 32 will be the, let me take the, another color. [00:44:09] There is the, there is the, another color. [00:44:15] Yeah. [00:44:16] 1 multiplied by 32 will be the 32. [00:44:21] Okay. [00:44:21] And this is converted. [00:44:23] This is achieved with the set technique, because it is the input sequence. [00:44:27] And this is the mathematical numerical, uh, format. [00:44:30] This is the encoded format. [00:44:32] Okay. [00:44:34] But here, in this case, we are not achieving this thing. [00:44:38] Two multiplied by 32 is 64, but we are getting 32. [00:44:48] Got the thing? [00:44:49] Or, any other questions? [00:45:11] Okay. [00:45:11] So, basically, if I ask, in the code only, not here, why, uh, okay, so, basically, uh, in [00:45:30] the dense layer, why, uh, we are using 1 here? [00:45:35] Just asking simple question. [00:45:36] Why we are using 1? [00:45:37] Okay. [00:46:11] So, yes or no? [00:46:15] Then, I can ask, why am I making it as 2 when I am, uh, increasing, increasing the number [00:46:23] of layers? [00:46:25] If the output is 1, how can we extract the output from, how can we expect the output as [00:46:32] a number of 2 outputs? [00:46:35] Can we expect? [00:46:36] Okay. [00:46:41] So, is it not 1, as we increase the number of layers or not, or as we increase the number [00:46:51] of dimensions or not? [00:46:52] Is it not 1? [00:47:04] We can increase the number of layers, but for that, we have to also increase the number [00:47:28] of dimensions. [00:47:29] Okay. [00:47:31] Like, first, we are reducing the dimension up to 128, then coming the 64, then coming to [00:47:36] see the 32, then coming up to the output as 1, because only one output is coming from the [00:47:43] architecture or any model. [00:47:46] Okay. [00:47:47] Now, got the concept why it is giving the error that the shape is not correct. [00:47:56] Okay. [00:47:56] So, let me write the same code one more time. [00:48:06] Okay. [00:48:07] So, let me write the same code one more time. [00:48:18] Okay. [00:48:19] You will get the things that how the things work. [00:48:23] Okay. [00:48:24] Let me paste it here. [00:48:26] Okay. [00:48:27] Now, I will change it accordingly. [00:48:30] Okay. [00:48:33] The output dimensions, I will change to 64. [00:48:35] Okay. [00:48:36] Here, I will also change to 64 and use some activation goals. [00:48:51] You can say, tanh and return sequences equals to true. [00:49:02] Okay. [00:49:03] And I will just copy this line and ctrl v and here the 64 and the same and I will not return [00:49:20] the sequences here because directly I want to compute the things. [00:49:27] Okay. [00:49:28] Then, I will add one more layer of the dance as I have to convert it to 32 units. [00:49:41] Okay. [00:49:43] Now, I can convert it into 2 because 32 x 2 is 64. [00:49:53] As I am using two dance layers, 32 x 2 is 64. [00:49:58] Now, let us see. [00:49:59] Will it compile or not? [00:50:14] Okay. [00:50:16] This thing is fine. [00:50:21] Loss equals what we are using currently. [00:50:24] Just copy and paste it. [00:50:25] This thing. [00:50:26] Okay. [00:50:27] Now, we will also see the model summary. [00:50:29] Okay. [00:50:32] Now, let us try. [00:50:34] to fit the model. [00:50:35] Here. [00:50:36] Okay. [00:50:38] So, what we can change here though. [00:50:39] Okay. [00:50:40] Now, we will also see the model summary. [00:50:41] Okay. [00:50:44] Now, let us try. [00:50:45] To fit the model. [00:50:46] Here. [00:50:47] Okay. [00:50:48] So, what we can change here though. [00:50:51] Up to the batch size of not 64. [00:51:07] It will be. [00:51:08] Let us try. [00:51:09] I am just trying. [00:51:10] Let us first try with 64. [00:51:12] What happens? [00:51:14] Okay. [00:51:16] So, I have forgotten a comma. [00:51:19] Okay. [00:51:20] So, you can see here. [00:51:23] It is our. [00:51:24] You can see architecture. [00:51:27] First is embedding. [00:51:28] Then the simple RNN. [00:51:30] Then the simple RNN again. [00:51:31] Then the dense layer. [00:51:32] And again the dense layer. [00:51:34] But the parameters are not called. [00:51:36] Basically, it is giving the line in this layer. [00:51:39] This. [00:51:40] During the training. [00:51:44] Meaning. [00:51:45] What? [00:51:46] It is against in the target and output. [00:51:48] Must have the same dimension. [00:51:49] Okay. [00:51:50] The target dot shape as none. [00:51:52] Comma. [00:51:53] Nothing. [00:51:54] But the output shape as none. [00:51:55] Comma. [00:51:56] 2. [00:51:57] Basically, we have defined here as. [00:51:58] Comma. [00:51:59] 2. [00:52:00] 2 cross 32. [00:52:01] So, we have to keep the batch size as 32. [00:52:06] What I am thinking currently. [00:52:08] So, let us try now. [00:52:10] Now. [00:52:11] Now you can see here. [00:52:14] Again, it has given same error. [00:52:17] Why? [00:52:18] Because. [00:52:19] We are not getting 2 cross 32 as 64 here. [00:52:29] As we are. [00:52:30] Only get 1 output. [00:52:32] Not 2 outputs. [00:52:33] Here we are getting only 1 output. [00:52:36] But here we are calling as 2 outputs. [00:52:43] Now. [00:52:44] Got some clarity. [00:52:46] Why? [00:52:47] It is giving the error. [00:52:49] The output will be 1 only. [00:52:51] The output cannot be 2 outputs. [00:52:56] Got the point. [00:52:57] Why? [00:52:58] It is giving the issue. [00:53:04] Any questions? [00:53:05] Any queries? [00:53:06] Again, you can ask. [00:53:07] It is a very important thing. [00:53:11] Any queries? [00:53:34] Okay. [00:53:35] Basically. [00:53:36] What I am doing. [00:53:39] Basically. [00:53:40] We have to reduce up to 32 layers. [00:53:43] Because we do the dimensionality reduction. [00:53:45] We can also reduce it to 16 to 4. [00:53:47] But. [00:53:48] Optimistically. [00:53:49] We take the 32 units. [00:53:52] We can also take up to 64. [00:53:54] But. [00:53:55] As we have increased the number of layers. [00:53:57] We have to also increase the dimensions from whichever we are taking from. [00:54:02] As we increase the number of layers. [00:54:04] You can say what currently we are doing here. [00:54:07] If I visualize it in a simple manner to you. [00:54:12] We are doing something like. [00:54:16] This is our input. [00:54:18] Okay. [00:54:19] Or. [00:54:20] I am not taking the input layer. [00:54:22] Okay. [00:54:23] This is up to the 64 neurons. [00:54:28] Okay. [00:54:29] Something like. [00:54:31] This thing. [00:54:33] Now. [00:54:34] We are reducing this layer up to the. [00:54:36] 32 neurons. [00:54:38] Okay. [00:54:39] Up to. [00:54:41] Here. [00:54:42] Okay. [00:54:44] And then. [00:54:45] What we are doing again. [00:54:46] Okay. [00:54:47] Not. [00:54:48] In. [00:54:49] Between this. [00:54:50] We have again. [00:54:51] One. [00:54:52] 64. [00:54:53] Neuron layer. [00:54:54] Then. [00:54:55] We are reducing it. [00:54:58] Okay. [00:54:59] But. [00:55:01] As we have this. [00:55:02] Two. [00:55:03] 64. [00:55:04] Uh. [00:55:05] Layers. [00:55:06] Two. [00:55:07] 64. [00:55:08] Neuron based layers. [00:55:09] That's why. [00:55:10] We are. [00:55:11] Trying to do. [00:55:12] One. [00:55:13] More. [00:55:14] Two. [00:55:15] Output. [00:55:16] Based. [00:55:17] Neurons. [00:55:18] In the dense. [00:55:19] Okay. [00:55:20] That's. [00:55:21] We are trying to do. [00:55:22] Which is. [00:55:23] Incorrect. [00:55:24] Fundamentally. [00:55:29] Got. [00:55:30] The. [00:55:31] Idea. [00:55:32] Any. [00:55:33] Questions. [00:55:34] Any. [00:55:35] Doubts. [00:55:36] Again. [00:55:37] You can. [00:55:59] Write. [00:56:00] The. [00:56:01] Question. [00:56:02] In chat. [00:56:03] I am. [00:56:04] Waiting. [00:56:05] Here. [00:56:06] You. [00:56:07] Can. [00:56:08] Write. [00:56:09] The. [00:56:10] Question. [00:56:11] In chat. [00:56:12] I am. [00:56:13] Waiting. [00:56:14] Here. [00:56:15] Yes. [00:56:16] Yeah. [00:56:21] Correct. [00:56:22] Uh. [00:56:23] The. [00:56:24] Dimension. [00:56:25] Will. [00:56:26] Be. [00:56:27] Increased. [00:56:28] I can. [00:56:29] Also. [00:56:30] Take. [00:56:31] Here. [00:56:32] As. [00:56:33] 32. [00:56:34] But. [00:56:35] It. [00:56:36] Will. [00:56:37] Not. [00:56:38] Make. [00:56:39] The. [00:56:40] Can. [00:56:41] Also. [00:56:42] Take. [00:56:43] Here. [00:56:44] We. [00:56:45] Will. [00:56:46] Not. [00:56:47] Make. [00:56:48] The. [00:56:49] Case. [00:56:50] Why. [00:56:51] Because. [00:56:52] The. [00:56:53] Model. [00:56:54] Will. [00:56:55] Be. [00:56:56] Getting. [00:56:57] No. [00:56:58] Advantage. [00:56:59] With. [00:57:00] That. [00:57:01] Okay. [00:57:02] Any. [00:57:03] Questions. [00:57:04] You. [00:57:05] Can. [00:57:06] Again. [00:57:07] Read. [00:57:08] The. [00:57:09] Line. [00:57:10] What. [00:57:11] Has. [00:57:12] It. [00:57:15] Been. [00:57:16] Given. [00:57:40] Any. [00:57:41] Questions. [00:57:42] Any. [00:57:43] Questions. [00:57:44] Any. [00:57:45] Questions. [00:57:46] Any. [00:57:47] Questions. [00:57:48] Any. [00:57:49] Questions. [00:57:50] Okay. [00:57:51] So. [00:57:52] Now. [00:57:53] Let. [00:57:55] Us. [00:57:56] Try. [00:57:57] With. [00:57:58] Out. [00:57:59] To. [00:58:00] Uh. [00:58:01] Let. [00:58:02] Us. [00:58:03] Try. [00:58:04] With. [00:58:05] To. [00:58:07] that. [00:58:08] To. [00:58:09] Transcriber. [00:58:10] To. [00:58:15] An. [00:58:16] Is. [00:58:17] To. [00:58:19] Part. [00:58:20] To. [00:58:28] will it work no okay i have written incorrect [00:58:38] why it worked [00:58:56] i don't see anything [00:59:13] because we are using here the binary and cross entropy can any loss function [00:59:25] calculate the in the binary case if we are using the multiple dimensions of the two of the [00:59:32] categorical outputs that is the key thing [00:59:43] got the idea any more questions [00:59:47] any other questions regarding to fundamental question or fundamentally why it worked or [01:00:03] why it not worked because now we are using the two classes as a category not as a class [01:00:10] okay you can you can also say that we are using a loss function which can also work on [01:00:17] two or more classes [01:00:19] previously we are using only the functions which will be work on two classes yes or no [01:00:29] currently currently what we are using yes no or some other possibility [01:00:34] got the thing [01:00:38] okay so now moving to moving to lstm [01:00:47] the same thing will be there we will be using the same data the same padding [01:00:56] okay now here we will be using two lstm layers okay [01:01:05] we will be also defined one more parameter that is the dropout of 0.5 what is the dropout [01:01:17] basically if i if i ask uh you have given a number of neurons in a particular layer and you have to [01:01:32] deactivate uh some neurons during training [01:01:37] okay yeah you can also say that the uh leave that neuron uh training during other training uh data [01:01:47] okay leave that neuron during training okay so that is the known as dropout layer okay why we do it [01:02:00] why we do it [01:02:04] basically if dropout is not there suppose our model is too complex to handle the data will it not uh [01:02:14] uh achieve the uh you can say uh will it not achieve the uh you can say overfitting okay because [01:02:33] if it is taking too much less time to converge uh during training basically what it means it will learn too [01:02:43] much to test uh it on the test data okay so according to the data set we make the model [01:02:53] simple okay if it is a complex model so that's why we use the dropout [01:03:03] okay [01:03:06] any questions [01:03:13] uh [01:03:28] not uh actually the bookish model basically uh uh we call it uh suppose uh i will be using the pre-trained [01:03:38] uh an encoder decoder based architecture or gpt based architecture for this [01:03:43] simple data set will it work for this uh thing it will give you good performance in three epochs [01:03:50] or you can say five epochs okay but what but what if for the hundred epochs basically we train our model [01:03:59] for the hundred epochs if i take a real life example what if uh suppose uh i i am i am teaching a batch of [01:04:07] uh 50 students some uh one student is too intelligent to learn okay it learns the things in [01:04:14] very less time but i have to take the average i do not have to uh take only that particular student [01:04:24] who is learning at a good good pace okay because accordingly his mind is converging in a less time [01:04:32] okay so basically it is learning the things too fast but it can also happen if he is or she learning in [01:04:39] in a to uh go in a good manner it may happen that he or she may become overconfident and in the exam or [01:04:48] in the test it may fail to give the correct answers it may happen so we take also that probability it may [01:04:58] happen that on the test data it may not give the uh correct uh performance on the test data or the good [01:05:08] performance on the test data okay any questions [01:05:22] okay so basically uh [01:05:24] uh okay so uh this is a uh uh you can say very uh [01:05:39] deep rooted question suppose if you also want to decide [01:05:47] which neuron to deactivate suppose if we talk about this thing [01:05:54] we have taking another symbol again layers [01:06:06] and just assume they are interconnected okay [01:06:17] now i want [01:06:18] that i want to deactivate this neuron [01:06:34] okay one thing i have if i using the private libraries okay i can do the simple math dropout 0.5 50 [01:06:42] percent for this layer will be deactivated 50 percent of the neuron of this layer will be deactivated but [01:06:50] it can happen during the uh again forward propagation training okay it will be activated [01:07:04] this neuron will be activated and this neuron will gets deactivated it can happen [01:07:10] if i talk about the 50 percent rule [01:07:15] will it happen or not or may it happen or not [01:07:22] so basically you can decide layer in layers that how much percent of neurons to deactivate but there [01:07:32] is also one solution if you want to decide that how much particular or the position of neurons or [01:07:41] the uh uh particular number of neurons you want to deactivate uh okay just write a particular layer [01:07:49] from layer wise like keras dot layers and the number of neurons in that layer with the activation function [01:07:56] and our sequence is returning okay just define in that case drop out [01:08:04] this particular neuron and make an index this particular neuron will be dropped okay but currently [01:08:13] we are not using that scratch idea we are just using the imported libraries as we are importing the lstm we [01:08:20] are importing the rnn we are importing the gru okay so currently we are we can just define the percentage [01:08:27] we cannot define the position or placing of that particular neuron to be deactivated [01:08:41] okay so basically the conclusion of this basically they are picked randomly as i told if i do the 50 percent [01:08:56] math it may happen during training the upper neuron will get deactivated [01:09:01] okay any questions any more questions [01:09:09] yeah uh actually the time will not allow this as the 50 minutes are only remaining we will be covering if [01:09:32] if time allows okay first we will complete up to the gru okay so just currently see here we are uh [01:09:40] converting it to the 64 dimension 64 number of units okay then we will be reducing the dimension up to [01:09:47] 432 number of units and the output as one okay [01:09:53] okay [01:09:58] got it then we will be doing the same thing uh training the model and compiling the model [01:10:06] training dot dot fit and epochs you can take others and with the bash size here what is what was [01:10:14] happening before we are using the binary cross entropy but with uh what binary cross entropy will do it it [01:10:20] will do only the yes or no the output will be the in the yes or no okay so that's why it was one [01:10:27] when we take the cross and categorical cross entropy or the sparse critical cross entropy it will decide [01:10:33] in the into the categories okay so we can define it as two as it is currently for binary classification [01:10:40] not multi-class classification got the point what was the previous error okay [01:10:50] because we are just reducing the dimension of the each uh layer okay [01:11:01] now moving forward to the gru as here you can see the same thing that running with the same as uh i i [01:11:09] think you know what does what are these things it is the best size like how much data on the first epoch [01:11:17] is it is passed on in the first batch [01:11:23] got it in the first batch it how much data is passing on [01:11:36] it depends if you are using predefined lstm layers you have to hit and try like how [01:11:45] how much dropout will be required first you have to think logically according to your data suppose [01:11:50] there are two classes yes or no but no number of classes are less than yes number of classes [01:11:56] so what you can do uh when you are if yes number of classes are more just when the data is training on [01:12:04] yes number of classes just try to drop neurons at that time during training because no number of classes [01:12:11] there are no number of uh classes are less okay so the model will train accordingly in a optimistic manner [01:12:21] for the yes number of classes but if you are making your model any model rnn lstm gru from scratch [01:12:29] like writing keras dot layers dot uh in the bracket uh number of neurons and everything and also [01:12:38] dropout rate and also defining which now which neuron to drop okay so you will get the idea that uh [01:12:47] accordingly that how much layers do you need and which neurons should drop and [01:12:54] that time you will get the correct uh intuition that okay uh this number of neurons which i can [01:13:01] drop okay but if you are using imported as i told you have to do the things by yourself experiment by yourself [01:13:11] okay so here uh it is the same training history like the training and loss if you just uh [01:13:21] flip the plot you can see the same plot as the loss [01:13:25] okay it is the same plot as the loss okay [01:13:34] so moving forward so this is the again uh this is the gru i think you are aware of what is lstmrn and gru [01:13:43] are you aware the thing are other things are covered in the theory class [01:13:55] okay okay so now the uh [01:14:03] okay we'll be looking into gru if it if the time uh the time allows okay so here we have used the same [01:14:15] method but only called the uh in place of lstm we call the gru indicated recurrent unit okay [01:14:22] so the same thing is there and for the binary classification for with the same number of [01:14:29] neurons with the same number of drops and everything was same just we use the gru layer in place of [01:14:36] lstm okay and we use the same thing and uh you can see the again the training and validation [01:14:47] accuracy and loss so basically what was the idea [01:14:54] there are two things uh if i take the questions of you guys [01:15:02] no this is correct not is the correct statement that gru is far simpler and faster alternative to lstm it [01:15:09] applies to some some predefined conditions okay now i will take your question so the first question was [01:15:22] what uh if the return sequences if are set to true if i set them to false what will happen basically [01:15:30] the data which is computed with the input data which is computed in the previous layer [01:15:36] the output of that data will not be passed in the uh second layer during the forward propagation okay [01:15:52] so uh let me read this question one more time [01:15:57] uh suppose uh this is one lstm cell in which all the gates are present okay this is one lstm cell [01:16:22] okay in which all the gates are present uh okay [01:16:30] now i have the another lstm cell in which all the things are present okay and here i am giving the input data [01:16:43] now the question is that in lstm will it work or not as [01:16:49] as we do it the uh with the recurrent with the of a fundamental concept of recurrent that the data [01:16:58] will occur recurrently so for the input data i will also mark one this thing okay what will happen [01:17:09] the input data will go first here okay some computation will happen in the this cell okay and [01:17:18] the output the output if i set if i set to true the return sequence equal to true it will go again to [01:17:26] the second uh lstm layer and the concept of recurrence will work and the previous data will also be stored [01:17:36] in this lstm layer and it will be again forwarded into some other layers if are present and it will be [01:17:43] also the input data will be also forwarded in the other layers okay but but if i set to false what will [01:17:52] happen this data will not be uh sorry the completed data of the first lstm cell will not be sent into the [01:18:04] second lstm cell only the previous input data will be sent okay got the answer [01:18:19] what the answer so uh okay [01:18:21] okay okay so uh now for gru basically uh [01:18:33] if i ask for lstm [01:18:38] what are the gates of lstm [01:18:39] what are uh their names the gates then i will uh tell you gru how it works here only [01:19:03] okay okay the one is the input gate one is the output gate and one is the forget gate the input [01:19:12] gate what it does basically it takes the input the output gate what it does it just compute the things [01:19:19] and uh sorry uh it will just gives us the output and what the forget gate does it just uh calculates [01:19:29] the things which uh things are not uh suitable for the cell and which things to forget from the cell [01:19:38] correct okay now how gru comes into play as we have here the three gate gru just optimizes this uh [01:19:49] architecture in the uh two with the two gates replacing them with the two gates one is the reset gate [01:19:56] one is the update gate now how reset gate works we have the input data okay if i talk about the lstm cell [01:20:08] let us take one lstm cell with the simple lstm cell one cell i will only take [01:20:15] okay so suppose i have this input gate i will not uh building the current architecture i am just [01:20:22] taking the components okay this is the forget gate and this is the output gate [01:20:32] okay so here the input [01:20:42] the output [01:20:44] and here is the forget gate okay [01:21:00] okay now basically there are three gates so what happens here due to information overflow because it is [01:21:08] a recurrent to the recurrence of again and again input data vanishing gradient occurs during training [01:21:16] slightly uh [01:21:20] early as compared to gru why because there are three gates and although three competitions are going on [01:21:27] current uh recurrently okay again and again [01:21:30] okay what gru does it just converts them into two gates one is the reset gate [01:21:38] okay okay and one is the update gate [01:21:43] okay this is the reset gate okay so what basically update gate does it works as the combination of the [01:21:52] forget and input gates of lstm this gate and the disc gate basically it will update the information [01:22:04] what information what information is coming from the input data okay [01:22:10] and the reset gate will decide what information to forget during training this reset gate will decide what [01:22:21] information to forget basically this update gates also gives uh things as the input and the forget it [01:22:32] uh acts as the combination and it gives us the output okay [01:22:40] so basically there are two gates okay the reset gate and the update gate so any questions any more doubts [01:22:49] then i do not understand this question uh any chart we can refer showing this lstm mapping with [01:23:06] different gates okay so any more questions any doubts any queries you can ask [01:23:19] any question [01:23:40] Thank you. [01:24:10] Okay, so the guys who have the questions, you can drop in the chat. [01:24:20] I will answer them accordingly. [01:24:26] For those who have no questions, so thank you so much. [01:24:29] So currently we have introduced with the RNN, simple RNN, vanilla RNN is not covered. [01:24:36] Basically it is a variant, so you have to try it by yourself. [01:24:39] Okay. [01:24:40] So the simple RNN is covered, then LSTN, then we will be, we have seen the GRU part also. [01:24:51] Okay. [01:24:53] So in the next upcoming class, we will be seeing the encoder, decoder part, the transformer, [01:24:59] if possible, its applications like BERT, GPT, GPT-2. [01:25:03] Okay, then how the applicability of today's LLMs. [01:25:06] Okay. [01:25:07] If possible. [01:25:08] Okay. [01:25:11] Any questions? [01:25:12] I will try, but I think it is not in my hand. [01:25:27] Let me stop sharing my screen, but I can just try. [01:25:33] Okay. [01:25:36] Thank you. [01:25:36] Okay. [01:25:36] Let me stop sharing your screen. [01:25:38] You