# Advance Machine Learning

- **Course:** 6103 - Advanced ML
- **Recorded:** 2026-11-14 09:33
- **Transcript:** 900 segments, 7426 words
- **Made by:** colab import

---
So basically what is basically there are various variants of R and we will be only looking at currently simple RNN okay so there is vanilla RNN also which you can try okay so currently what we are doing here is importing IMDB dataset okay from tensorflow I think tensorflow you guys all aware of tensorflow keras pytorch etc okay then we are importing a pre-processing technique known as sequence why sequence because as the data is textual okay so that's why and the data is of in sequences like you can say a sentence sentence is what a sequence of words okay so that's why we are importing sequence okay then we will be importing the features that way basically it is the vocabulary size what is the vocabulary size basically how many words can be kept to reduce the dimensionality now I think you guys know what is the dimensionality okay then what can be the maximum length of a review data okay got my point up to here

okay then there is nothing then splitting the data into training and testing sets one is uh x is the uh or uh you can uh independent variable and y is the target variable okay for the same test data okay x and y for this all splitting uh after splitting these things we are importing we are sorry loading the data of IMDB with how number of words will be the maximum number of features basically this number of of words are kept okay in during loading these this IMDB data any queries until here yeah uh basically we will be uh uploading uh the things okay first uh the things when will be completed and then we will be uploading and we'll be covering all the things like transformer and coda decoder okay then comes the gpt basically it is the uh you can say uh application of uh transformer okay so basically you will be uh seeing it analyzing it in an application oriented manner okay okay any questions any other questions

any other questions okay so uh uh now now moving forward okay now uh anyone knows what is padding in uh text data uh or image data everyone knows i i think i assume everyone knows what is padding okay so we are doing nothing but in training data we are also uh using padding in which each review is padded with maximum length of review suppose the review say length is only 400 so it will be padded with 100 more uh words okay like to uh maximize the its length to 500 okay if the length length is 200 then it will be padded then it will be padded with it will be padded with 300 okay so so same is the case with test data okay here we also doing padding to keep the thing same okay so any question in in this first cell any question okay okay okay so uh uh let me uh take the uh one example okay for uh instance suppose our maximum length is 10 okay because i cannot write here in 500 sick uh maximum length okay suppose our maximum length is 10 okay now i write a word wish okay

okay wish you good morning okay so basically if i look here uh how many uh how many uh you can say uh sequences are there how many sequences suppose this is a sentence okay how many sequences are there can anyone tell okay okay so if i take about at a void level only void level so there are four sequences if i take about a character level so there are one two three four space five then up to like more than uh 15 sequences okay so currently we're taking at the void level okay okay okay now as i said let us suppose the maximum length is 10 for instance okay so currently we have only uh four uh see uh four sequences okay so how the padding will work this is i am telling only an application of word uh one technique i have taken a uh random sequence from the data itself a wish wish okay and before also some good so how many uh six are there okay then you seven eight and here also nine and one more 10 okay so this is a one technique now search it's by yourself that which technique it is okay

because i will not tell this what is the name of this technique okay so that's how padding works basically we have to make the sequence up to 10 okay because the input will work like that okay as we have defined that the maximum length of the data will be 10. got the point or any more questions okay so so uh now moving forward so clear with the first cell how how the things are working here the maximum length is 500 so we are filling it with uh the remaining uh uh sequences okay now moving forward so now here we have uh a simple rnn model basically simple what simple means we have only one embedding layer this is the embedding layer where uh the input dimensions are maximum number of features basically this number of features okay and the output dimensions that we have defined is 32. now can anyone tell how the dimension reduction will work from this 10 000 to 32 anyone knows mathematically anyone knows

yeah this is a one technique okay so basically you you you can use various techniques to reduce the dimensionality okay using pca or using psne etc okay where so now moving forward where the input length is the maximum number of length that is 500 you can directly here write 500 also but actually why we do not do so because if typo errors are there so from my error i have written i have written 400 so error will come okay so that's why we define a variable and directly refer to it that it is the maximum length of the uh input okay so now we have defined a simple rnn with the of 32 units what is what is meant by units anyone knows what is meant by units uh and like yourkeeping the uh um it is the number of neurons okay basically so basically we have the 32 number of neurons to handle the dimension of 32 okay so this thing we basically try to keep these things in a simple manner okay so that's why we have defined so each neuron will will keep one dimension okay so you

can correlate with it so at the output we get a one dimension output and we have then defined activation function of sigmoid because it is a binary classification task so so got the point that how the thing is working how how we have reduced the dimensions and then how the output of dense is coming because every neuron is handling one one dimension at each time so the output neuron will also handle the only one dimension and it can only give one output okay there cannot be multiple outputs in machine learning this is a basic fundamental okay so that's why we we have a one one output layer for the binary classification okay so any questions in this cell any questions okay so so moving forward so you can directly calculate here you can directly what we basically do we compile the model with optimizer we can uh we will also change the loss we will also uh uh change the activation function okay we will uh let us hit and try okay because uh currently what we are seeking though basically in deep learning

initially we do not know which uh uh optimizer or which activation function or which uh uh loss function will be suitable for our data set okay i am talking about the suitability of uh model and the data okay currently we have binary classification so we know that only two classes are there so it will be a sigmoid function but what it will be the multiple classes okay what if the features are different okay currently we have only uh two features that is the sentence and that is the uh second is the uh uh review that it is a positive or the negative okay but what if there are multiple features okay so how to handle that thing so we are going in a that that direction okay we will be look looking into that that that how the performance of a model works if change if we change the optimizer function the activation function and the uh different different uh parameters okay so let us run this cell okay so in between if you guys have any more questions or so you can ask okay

now moving forward to tensorflow the second cell now we will compile the model and we will run the uh we will train the model on only let us try to up to three epochs so that we can note its value okay so here you can also see we have splitted our data into validation also point two means what 20 percent of the training data we have splitted for validation so suppose we have 100 percent of the data data we have kept for uh we have first we separated our test data after that during the training uh time we have also separated our validation uh data so that we can validate our training that how it is performing so currently just note down that currently the training uh performance is 92.16 okay and the validation is 80.48 okay now we will do some uh parameter tuning or uh normally we call it as hyper parameter tuning okay so what can be the other sigma other uh activation functions what can be the other activation functions

uh i am talking in a classification task only apart from sigmoid what can be the activation function yeah we can use uh softmax as it is uh basically suit basically sigmoid is best suitable for binary classification but for the main time we are using softmax okay then what can be the optimizer one is adam w then next what can be the optimizer what can be the optimizer okay so i am just for the meantime i am taking about the item w okay loss will be i am taking same as the binary cross entropy okay yes we can use uh the softmax function in the intermediate layer but as we have only one layer like the input is coming and the output is seeking though okay okay if uh if uh if if we can increase the dimensions up to 64 like uh i will also do that thing uh okay if the time uh the time foundation is not there because we have also cover lstm and gru okay then we can also try that like what we have to do we have to just copy these three lines okay then

simple rnn up to 64 neurons okay then dense up to two then there is one activation function okay as the or you can say directly here then again simple rnn 32 okay then at last the output layer will come with the dense function okay okay got the point any question okay so now let us run the cell as we have changed the things um okay uh okay uh um okay oh it's okay it's So now here you can see that the accuracy has dipped to 50 and the validation has also dipped to 49. So you can see here that how optimality can be achieved with the suppose we have seen this one first and then I will show you the previous one in the second show. So what does it indicate that basically we have to test each and every parameter on the optimizer thing, on the loss thing, on the activation function thing. We have to try each and every function for our data. Any more questions? Okay. So just let us try to make it between two layers. Okay.

So here I will write also one thing I have to here add and I have to also return the sequences of each embedding. Return sequences will it be true. Okay. Then I will again add this simple RNN here. Okay. Of 32. Okay. Now let us try to run it with which function did we used before sigmoid. Okay. And here the Adam optimizer. Okay. So now let us try with two RNN layers. Okay. So let us see what happens. Imagine. Okay. How do we make it? Okay. So let us try. Okay. Yeah. Okay. currently uh if if if anyone is looking closely okay return sequences basically means basically what the previous neurons are basically uh saving their uh values basically uh you have seen in machine learning or in the neural network itself that uh just a minute let me take a new file you have seen that i am building a typical neural network not a recurrent neural network okay we use it in all all uh places okay suppose this is a neural network okay and here and then here and this is the output then we have these interconnections

okay and then here it is one output okay what return sequences basically mean i will ask one question from where this neuron is getting well the value its value it is layer two okay from where this neuron is getting its value okay from previously uh it is getting its value so which which uh data will return uh its value to its neuron the previous layer as we are using sequences so that's why we use uh you can also uh see it like return sequences to this neuron from the previous layer so that's why we write return sequences equals to true so that we can get the data from the previous layer now the same concept works in rnn okay this is a typical neural network architecture here got the point now any questions apart from this this part after that i will ask one question any question okay okay so my question is this i have done a mistake intentionally in this line what is it return sequence is nothing but we are calling you can say the calling the data from the previous layer as

we have the dimension saved in the previous layer of rnn so we are just calling them in the current layer okay from the input layer to the layer one one why it should two yes the answer is correct this is actually two this will be actually two why because i have defined the two layers so the two layers will be become as input for this output layer but i have defined only one out one in out uh input layer for is it so this is wrong basically only this layer will be again giving its output and this layer will be getting dropped okay this layer will will not be connected with this output layer so here i will do the two okay now let us do one more thing as there is uh one more question of activation functions okay let us define uh activation function uh here uh activation equals we will be defining here what i i will define here let us try with tanh what can from which uh what activation functions can we take here

let us go with tanh okay here also we will be going through tanh okay okay this is fine so currently we have previously run all the cells so currently you can see here the accuracy is 89 and here is also the 84 so just um keep them in mind okay now it will it can change okay so let us see why this thing can anyone tell what is the issue okay again i have done this intentionally you Thank you. What is the difference? No. Now, I just told you in the starting of the class that if we take two layers, we have to increase our dimensions. Have we increased? First, if we are taking two and the output dimension is 32, what will be the output dimension here as it is the input thing? Will it not be 64? Here we also. Will it not be 64? Okay. And here also will it not be 64? Okay. Now, let us try. Okay. So, it has again gone into same error. Why is it so? Because as we have defined, basically what is happening here, as we have two classes and

the dimension is defined into 32 of the 32, you can say, okay, 32 cross dimensions. Okay. But what currently we are trying to do, the output we are trying to define the two, but here also we are defining in 64, 64 and 64. So, if we take 32, 32, 32 and 32 and it will take it as one. Okay. It will work. Why? Because the dimensions are same as we have only two classes. Okay. So, let us try to print our shape. Okay. X shape. Okay. This is the shape. Okay. Now, you can also print for the Y train. Okay. In the same and in the same manner and for the same test manner, for the test case, you can also do the same task. Okay. Got the point? Now, I will add only one thing. As we, uh, as we, uh, want the 32 dimension, the thing. Okay. What if I do? If I add one more layer. Dance off. I only have to convert it 32. What can we take the activation function? As we have take the 10H. Okay. Should we take ReLU or Leaky ReLU? Let us try with ReLU.

Okay. So, here it is this. So, we have run this cell. Okay. Let us try with this and this. So, again. Okay. So, I think it will not work because as we have typically defined here with the 32 dimensions. Okay. So, we will try, uh, uh, after some time, uh, this thing. Okay. Let us move forward. So, basically, just, uh, doing the control Z. And this is the basic, this was the basic thing. Okay. So, now, basically, how, basically, you predict, uh, the test accuracy and the test loss. Okay. This is the key thing. Okay. So, just waiting for it to finish. Yeah, I will explain that thing. Okay. I will just explain. Just a minute. Just see the plots and then I will explain what is the difference. Okay. Then, we will be covering. So, basically, this is the training, uh, you can say plot. This is the training accuracy and validation accuracy. Okay. And if you just, uh, you can say flip this plot, the accuracy plot, you, you can correlate with this.

That it is going in the loss. Okay. In the loss direction. Okay. Got till point here. Got the point till here. Then, we will talk about the target shape mismatch. Okay. When it happens and why, why it happens. Okay. Basically, why it happens. So, basically, what is happening currently, uh, let us again open my paint. Uh, yeah. Okay. We have an input sequence of currently 500, uh, sequences. Okay. As we have defined our 500 sequences. Okay. Now, what, uh, we are trying basically, to reduce them in the 32 dimensions. Okay. To reduce them in the 32 dimensions. Okay. And then, will be the, one output layer will contain the output with the dimensional, uh, dimension of its output. Okay. Which will predict whether the, uh, review, uh, is positive or negative. Got the things? This is our default one. What, uh, our, uh, current code is working on. Okay. Now, what we are trying to do for the shape of activation. Okay. Uh, so, uh, how activation is also working, uh, you guys know, uh, how activation works.

I think you, you know, how activation works. Do you know, uh, how activation for works? Okay. So, basically, it is nothing but, it will calculate the probability, uh, basically, it will calculate, uh, the things of activation, which, uh, neuron will get, of the layer will get activated at that time or not. Okay. The same thing will, will go here. Okay. Now, basically, what we are trying to build, it to, is to convert it into something like the same input 500, of 500 sequences. Okay. Then converting it into 64 dimensions. Okay. Then, again, a simple RNN layer will come of the same 64 dimensions. Okay. Then, it will be handled with the layer of 32 units neurons. Okay. So, for the, each dimension will handle, each two dimensions will be handled. by one neuron. So, that's why the dance will be called as two. And, okay, which will be classified as, you can say here, the 32, because each layer will be handled by the two.

So, two into 32 will be the 64. We will be achieving the same dimension. Okay. And after that, we will be doing the same classification task. Positive or negative. Okay. We are trying. Okay. So, this is a, basically, good question. Why the output layer dimension is 1, 32? Just multiply it. How will it, how much it will be? For the simple RNN model, for the basic RNN model, just multiply it. Just, I will say the, do the back provocation. 1 multiplied by 32 will be the, let me take the, another color. There is the, there is the, another color. Yeah. 1 multiplied by 32 will be the 32. Okay. And this is converted. This is achieved with the set technique, because it is the input sequence. And this is the mathematical numerical, uh, format. This is the encoded format. Okay. But here, in this case, we are not achieving this thing. Two multiplied by 32 is 64, but we are getting 32. Got the thing? Or, any other questions? Okay.

So, basically, if I ask, in the code only, not here, why, uh, okay, so, basically, uh, in the dense layer, why, uh, we are using 1 here? Just asking simple question. Why we are using 1? Okay. So, yes or no? Then, I can ask, why am I making it as 2 when I am, uh, increasing, increasing the number of layers? If the output is 1, how can we extract the output from, how can we expect the output as a number of 2 outputs? Can we expect? Okay. So, is it not 1, as we increase the number of layers or not, or as we increase the number of dimensions or not? Is it not 1? We can increase the number of layers, but for that, we have to also increase the number of dimensions. Okay. Like, first, we are reducing the dimension up to 128, then coming the 64, then coming to see the 32, then coming up to the output as 1, because only one output is coming from the architecture or any model. Okay. Now, got the concept why it is giving the error that the shape is not correct.

Okay. So, let me write the same code one more time. Okay. So, let me write the same code one more time. Okay. You will get the things that how the things work. Okay. Let me paste it here. Okay. Now, I will change it accordingly. Okay. The output dimensions, I will change to 64. Okay. Here, I will also change to 64 and use some activation goals. You can say, tanh and return sequences equals to true. Okay. And I will just copy this line and ctrl v and here the 64 and the same and I will not return the sequences here because directly I want to compute the things. Okay. Then, I will add one more layer of the dance as I have to convert it to 32 units. Okay. Now, I can convert it into 2 because 32 x 2 is 64. As I am using two dance layers, 32 x 2 is 64. Now, let us see. Will it compile or not? Okay. This thing is fine. Loss equals what we are using currently. Just copy and paste it. This thing. Okay. Now, we will also see the model summary.

Okay. Now, let us try. to fit the model. Here. Okay. So, what we can change here though. Okay. Now, we will also see the model summary. Okay. Now, let us try. To fit the model. Here. Okay. So, what we can change here though. Up to the batch size of not 64. It will be. Let us try. I am just trying. Let us first try with 64. What happens? Okay. So, I have forgotten a comma. Okay. So, you can see here. It is our. You can see architecture. First is embedding. Then the simple RNN. Then the simple RNN again. Then the dense layer. And again the dense layer. But the parameters are not called. Basically, it is giving the line in this layer. This. During the training. Meaning. What? It is against in the target and output. Must have the same dimension. Okay. The target dot shape as none. Comma. Nothing. But the output shape as none. Comma. 2. Basically, we have defined here as. Comma. 2. 2 cross 32. So, we have to keep the batch size as 32. What I am thinking currently.

So, let us try now. Now. Now you can see here. Again, it has given same error. Why? Because. We are not getting 2 cross 32 as 64 here. As we are. Only get 1 output. Not 2 outputs. Here we are getting only 1 output. But here we are calling as 2 outputs. Now. Got some clarity. Why? It is giving the error. The output will be 1 only. The output cannot be 2 outputs. Got the point. Why? It is giving the issue. Any questions? Any queries? Again, you can ask. It is a very important thing. Any queries? Okay. Basically. What I am doing. Basically. We have to reduce up to 32 layers. Because we do the dimensionality reduction. We can also reduce it to 16 to 4. But. Optimistically. We take the 32 units. We can also take up to 64. But. As we have increased the number of layers. We have to also increase the dimensions from whichever we are taking from. As we increase the number of layers. You can say what currently we are doing here. If I visualize it in a simple manner to you.

We are doing something like. This is our input. Okay. Or. I am not taking the input layer. Okay. This is up to the 64 neurons. Okay. Something like. This thing. Now. We are reducing this layer up to the. 32 neurons. Okay. Up to. Here. Okay. And then. What we are doing again. Okay. Not. In. Between this. We have again. One. 64. Neuron layer. Then. We are reducing it. Okay. But. As we have this. Two. 64. Uh. Layers. Two. 64. Neuron based layers. That's why. We are. Trying to do. One. More. Two. Output. Based. Neurons. In the dense. Okay. That's. We are trying to do. Which is. Incorrect. Fundamentally. Got. The. Idea. Any. Questions. Any. Doubts. Again. You can. Write. The. Question. In chat. I am. Waiting. Here. You. Can. Write. The. Question. In chat. I am. Waiting. Here. Yes. Yeah. Correct. Uh. The. Dimension. Will. Be. Increased. I can. Also. Take. Here. As. 32. But. It. Will. Not. Make. The. Can. Also. Take. Here. We. Will. Not. Make. The. Case. Why. Because. The. Model. Will. Be. Getting. No. Advantage.

With. That. Okay. Any. Questions. You. Can. Again. Read. The. Line. What. Has. It. Been. Given. Any. Questions. Any. Questions. Any. Questions. Any. Questions. Any. Questions. Okay. So. Now. Let. Us. Try. With. Out. To. Uh. Let. Us. Try. With. To. that. To. Transcriber. To. An. Is. To. Part. To. will it work no okay i have written incorrect why it worked i don't see anything because we are using here the binary and cross entropy can any loss function calculate the in the binary case if we are using the multiple dimensions of the two of the categorical outputs that is the key thing got the idea any more questions any other questions regarding to fundamental question or fundamentally why it worked or why it not worked because now we are using the two classes as a category not as a class okay you can you can also say that we are using a loss function which can also work on two or more classes previously we are using only the functions which will be work on two classes yes or no

currently currently what we are using yes no or some other possibility got the thing okay so now moving to moving to lstm the same thing will be there we will be using the same data the same padding okay now here we will be using two lstm layers okay we will be also defined one more parameter that is the dropout of 0.5 what is the dropout basically if i if i ask uh you have given a number of neurons in a particular layer and you have to deactivate uh some neurons during training okay yeah you can also say that the uh leave that neuron uh training during other training uh data okay leave that neuron during training okay so that is the known as dropout layer okay why we do it why we do it basically if dropout is not there suppose our model is too complex to handle the data will it not uh uh achieve the uh you can say uh will it not achieve the uh you can say overfitting okay because if it is taking too much less time to converge uh during training basically what it means it will learn too

much to test uh it on the test data okay so according to the data set we make the model simple okay if it is a complex model so that's why we use the dropout okay any questions uh not uh actually the bookish model basically uh uh we call it uh suppose uh i will be using the pre-trained uh an encoder decoder based architecture or gpt based architecture for this simple data set will it work for this uh thing it will give you good performance in three epochs or you can say five epochs okay but what but what if for the hundred epochs basically we train our model 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 uh 50 students some uh one student is too intelligent to learn okay it learns the things in very less time but i have to take the average i do not have to uh take only that particular student who is learning at a good good pace okay because accordingly his mind is converging in a less time

okay so basically it is learning the things too fast but it can also happen if he is or she learning in in a to uh go in a good manner it may happen that he or she may become overconfident and in the exam or in the test it may fail to give the correct answers it may happen so we take also that probability it may happen that on the test data it may not give the uh correct uh performance on the test data or the good performance on the test data okay any questions okay so basically uh uh okay so uh this is a uh uh you can say very uh deep rooted question suppose if you also want to decide which neuron to deactivate suppose if we talk about this thing we have taking another symbol again layers and just assume they are interconnected okay now i want that i want to deactivate this neuron okay one thing i have if i using the private libraries okay i can do the simple math dropout 0.5 50 percent for this layer will be deactivated 50 percent of the neuron of this layer will be deactivated but

it can happen during the uh again forward propagation training okay it will be activated this neuron will be activated and this neuron will gets deactivated it can happen if i talk about the 50 percent rule will it happen or not or may it happen or not so basically you can decide layer in layers that how much percent of neurons to deactivate but there is also one solution if you want to decide that how much particular or the position of neurons or the uh uh particular number of neurons you want to deactivate uh okay just write a particular layer from layer wise like keras dot layers and the number of neurons in that layer with the activation function and our sequence is returning okay just define in that case drop out this particular neuron and make an index this particular neuron will be dropped okay but currently we are not using that scratch idea we are just using the imported libraries as we are importing the lstm we

are importing the rnn we are importing the gru okay so currently we are we can just define the percentage we cannot define the position or placing of that particular neuron to be deactivated okay so basically the conclusion of this basically they are picked randomly as i told if i do the 50 percent math it may happen during training the upper neuron will get deactivated okay any questions any more questions yeah uh actually the time will not allow this as the 50 minutes are only remaining we will be covering if if time allows okay first we will complete up to the gru okay so just currently see here we are uh converting it to the 64 dimension 64 number of units okay then we will be reducing the dimension up to 432 number of units and the output as one okay okay got it then we will be doing the same thing uh training the model and compiling the model training dot dot fit and epochs you can take others and with the bash size here what is what was

happening before we are using the binary cross entropy but with uh what binary cross entropy will do it it 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 when we take the cross and categorical cross entropy or the sparse critical cross entropy it will decide in the into the categories okay so we can define it as two as it is currently for binary classification not multi-class classification got the point what was the previous error okay because we are just reducing the dimension of the each uh layer okay now moving forward to the gru as here you can see the same thing that running with the same as uh i i think you know what does what are these things it is the best size like how much data on the first epoch is it is passed on in the first batch got it in the first batch it how much data is passing on it depends if you are using predefined lstm layers you have to hit and try like how

how much dropout will be required first you have to think logically according to your data suppose there are two classes yes or no but no number of classes are less than yes number of classes so what you can do uh when you are if yes number of classes are more just when the data is training on yes number of classes just try to drop neurons at that time during training because no number of classes there are no number of uh classes are less okay so the model will train accordingly in a optimistic manner for the yes number of classes but if you are making your model any model rnn lstm gru from scratch like writing keras dot layers dot uh in the bracket uh number of neurons and everything and also dropout rate and also defining which now which neuron to drop okay so you will get the idea that uh accordingly that how much layers do you need and which neurons should drop and that time you will get the correct uh intuition that okay uh this number of neurons which i can

drop okay but if you are using imported as i told you have to do the things by yourself experiment by yourself okay so here uh it is the same training history like the training and loss if you just uh flip the plot you can see the same plot as the loss okay it is the same plot as the loss okay so moving forward so this is the again uh this is the gru i think you are aware of what is lstmrn and gru are you aware the thing are other things are covered in the theory class okay okay so now the uh okay we'll be looking into gru if it if the time uh the time allows okay so here we have used the same method but only called the uh in place of lstm we call the gru indicated recurrent unit okay so the same thing is there and for the binary classification for with the same number of neurons with the same number of drops and everything was same just we use the gru layer in place of lstm okay and we use the same thing and uh you can see the again the training and validation

accuracy and loss so basically what was the idea there are two things uh if i take the questions of you guys no this is correct not is the correct statement that gru is far simpler and faster alternative to lstm it applies to some some predefined conditions okay now i will take your question so the first question was what uh if the return sequences if are set to true if i set them to false what will happen basically the data which is computed with the input data which is computed in the previous layer the output of that data will not be passed in the uh second layer during the forward propagation okay so uh let me read this question one more time uh suppose uh this is one lstm cell in which all the gates are present okay this is one lstm cell okay in which all the gates are present uh okay now i have the another lstm cell in which all the things are present okay and here i am giving the input data

now the question is that in lstm will it work or not as as we do it the uh with the recurrent with the of a fundamental concept of recurrent that the data will occur recurrently so for the input data i will also mark one this thing okay what will happen the input data will go first here okay some computation will happen in the this cell okay and the output the output if i set if i set to true the return sequence equal to true it will go again to the second uh lstm layer and the concept of recurrence will work and the previous data will also be stored in this lstm layer and it will be again forwarded into some other layers if are present and it will be also the input data will be also forwarded in the other layers okay but but if i set to false what will happen this data will not be uh sorry the completed data of the first lstm cell will not be sent into the second lstm cell only the previous input data will be sent okay got the answer

what the answer so uh okay okay okay so uh now for gru basically uh if i ask for lstm what are the gates of lstm what are uh their names the gates then i will uh tell you gru how it works here only okay okay the one is the input gate one is the output gate and one is the forget gate the input gate what it does basically it takes the input the output gate what it does it just compute the things and uh sorry uh it will just gives us the output and what the forget gate does it just uh calculates the things which uh things are not uh suitable for the cell and which things to forget from the cell correct okay now how gru comes into play as we have here the three gate gru just optimizes this uh architecture in the uh two with the two gates replacing them with the two gates one is the reset gate one is the update gate now how reset gate works we have the input data okay if i talk about the lstm cell let us take one lstm cell with the simple lstm cell one cell i will only take

okay so suppose i have this input gate i will not uh building the current architecture i am just taking the components okay this is the forget gate and this is the output gate okay so here the input the output and here is the forget gate okay okay now basically there are three gates so what happens here due to information overflow because it is a recurrent to the recurrence of again and again input data vanishing gradient occurs during training slightly uh early as compared to gru why because there are three gates and although three competitions are going on current uh recurrently okay again and again okay what gru does it just converts them into two gates one is the reset gate okay okay and one is the update gate okay this is the reset gate okay so what basically update gate does it works as the combination of the forget and input gates of lstm this gate and the disc gate basically it will update the information

what information what information is coming from the input data okay and the reset gate will decide what information to forget during training this reset gate will decide what information to forget basically this update gates also gives uh things as the input and the forget it uh acts as the combination and it gives us the output okay so basically there are two gates okay the reset gate and the update gate so any questions any more doubts then i do not understand this question uh any chart we can refer showing this lstm mapping with different gates okay so any more questions any doubts any queries you can ask any question Thank you. Okay, so the guys who have the questions, you can drop in the chat. I will answer them accordingly. For those who have no questions, so thank you so much. So currently we have introduced with the RNN, simple RNN, vanilla RNN is not covered. Basically it is a variant, so you have to try it by yourself.

Okay. So the simple RNN is covered, then LSTN, then we will be, we have seen the GRU part also. Okay. So in the next upcoming class, we will be seeing the encoder, decoder part, the transformer, if possible, its applications like BERT, GPT, GPT-2. Okay, then how the applicability of today's LLMs. Okay. If possible. Okay. Any questions? I will try, but I think it is not in my hand. Let me stop sharing my screen, but I can just try. Okay. Thank you. Okay. Let me stop sharing your screen. You

