Backpropagation Algorithm
Transcript
Welcome to my youtube channel Dhanesh here. This is the second video the second video on backpropagation algorithm So Please watch the previous video before getting into this So in the last video we discussed what is cost function how we can use this gradient descent algorithm what is the architecture of am neural network and How this some activation function how we can use the sigmoid function in this back propagation algorithm All these aspects are we covered in the last video? So please sub, you know get into the previous video before you know
Understanding this, you know before going through this video See in this video we are going to the you know getting into the mathematical steps how the forward propagation works and How the backward propagation works see this is what we are going to discuss in this video See how forward propagation going to happen two aspects. We are going to cover in this video First one is immuno or forward propagation The mathematical steps behind forward propagation second one is the mathematical steps behind a Backward propagation these two things. I Am going to cover Excuse me so before getting into these details I
Have to tell you inside an artificial neuron inside a perceptron Two things are happening It's a very simple it's very simple. You need know too, you know You know, it's easily you can understand that I'm telling one is it will calculate the weighted sum This is the two steps that is easy it is equal to you can write it as W 1 X 1 plus W 2 X 2 plus, you know P 1 Into 1 the weight of the bias is we usually take it as 1 this is the weighted sum the second step We will do is scratch it using an activation function Here we are using it as the sigmoid function It is denoted by the letter, you know, we can use it as Sigma Sigma of easy We will squash it using you know
the sigmoid function squash the weighted sum by using an activation function these two steps will Happen inside a neuro artificial noodle See how we will do it. I will show you in the Vino steps even in the last video I have find out them, you know a derivative of Sigma. You have to remember that activation function sigmoid at the activation function The sigmoid activation function Sigma you can write it as M you know 1 by 1 plus e raised to minus X the derivative of this function is
You got it as Sigma into 1 minus Sigma, please watch the previous video This is really important. We are going to use it in the most of the steps this equation because you needn't is so now I am going to tell both immuno forward bias and backward pairs and the mathematical steps behind that to get into those details You have to understand this simple architecture. This is the last video I have shown you this architecture input layer hidden layer output layer
This black arrows represents the weight everything I have told you please I know go through that as well this architecture, you know We are going to use it for for back forward propagation and backward propagation here. I 1 I 2 V 1 represents the input layer H1 h2 Wanda b2 that represents the hidden layer Oh 1 and Row 2 Represents the output layer of peas you can you you can see it 0.01 and 0.99 year 201 at o2. That is the target value. That is the actual value when you calculate the error this target value minus sum the even Predicted value will give the error see the error is some you know target
- predicted that will give you the error. So this is very important see our I'm on to tell you is from 0.01 and 0.99 are the target value? Target value and we are going to calculate the predicted value and we will check we will you know, you know check it with the you know, target value calculate the error and again, we will you know, update the weights and biases so That's fine. See what we are going to do it in the forward bias. I Can tell you it is you know I first I am explaining you what is happening inside the forward bias upset the steps some under?
forward bias So what's happening inside the forward bias is we will move from you can see this Architecture, we will move from i1 to over Here we will calculate the predicted output and calculate the error Error is predicted - actual or you can use actual - predicted because we are going to square it So whether it is positive or negative When you square it you will get a positive number Okay, so we will in the forward bias Sorry is not by its forward propagation inside the forward propagation We will move from I want to on here
We will calculate the predicted output then calculate the error error means Predicted - action or you can tell it as predicted - the target value the actual Value or the target value here. It is zero 0 1 & 0.99 0.01 401 and 0.99 400 K 1 and O 2 at the output layers part of output layer. I 1 I 2 V 1 part of input layer H 1 H 2 and up B 2 a part of the hidden layer So you understood that's what we do in the forward propagation inside the backward propagation if you see here
I told you the actual output is 0.01 and 0.99 inside backward propagations so next I'm going to talk about what's happening inside the backward propagation so inside backward propagation What you will do is We will We will go back. We will go back from oh one to I 1 and Update the weights and biases using gradient descent Such that the cost function or error function should be minimum
Once again in the backward propagation we will go back from oh one to I 1 and Update the weights and biases using gradient descent algorithm And so that the cost function or error function should be minimum So we got it after this backward propagation. We got a we will be getting with updated Weights and biases and by using this updated weights and biases again. We will do the forward propagation We will do the forward propagation. I am calculate the error
Again, and move backward by updating weights and biases and again use the gradient descent algorithm it will calculate the You know A minimum of the cost function thus finally we will get the global minimum of the cost function This is what we do it in the you know backward In the last video. I have explained you it a name very simple block diagram This is the model you are calculating the error using COS function If the error is minimum, we will check it if it is
No, we will update weight and bias of the network using lady in this and algorithm again We will back propagate that error using the COS function I'm you know, I am you know in the network and again calculate the cost function Sorry We will back propagate that error in that neural network Again, calculate the cost function and we will check whether the error is minimum or not if it is not minimum again the same process repeat we will you know, I trade for thousand or ten thousand times to get the minimum error minimum then if the error is minimum our model is ready for prediction this is what we do it in the Backward propagation we have already discussed that Enough of the to get it to get more clarity on that I am going to calculate each and every step. I want this, you know
Forward propagation festivai am going to do the mathematical step for forward propagation so you can see in the maths behind That's of forward propagation For that we are using the you know This architecture only we are using from this architecture We are calculating the net weight coming to the load H1 the circle represents the note So you can see the node edge front see what should be the net weight coming to the node edge one See two steps we will do for each node Is here we have the node H when the hidden layer H one so two steps when I am talking about the node H1 two steps I will do one is them I will calculate the weighted sum Coming towards that node. H1
Then after that squash that weight squash it using activation function So we weighted sum is easy. Then I will calculate Sigma of is it Sigma is the activation function? This is the two steps we use we do it in all the nodes whether it is h1 H2 o 1 o 2 everywhere here. I wanna die - just inputs there are no Weights coming to us. I'm gonna die - so we are not calculating that So first, I am calculating that net h1. So you have to understand this is the I
have told you already this is what happening inside a perceptron or a Artificial neuron first it will calculate the weighted sum the activation function represents the state of the artificial new door so that act activation functions here We activation function different types are there, you know sigmoid, you know run Liu Hyperbolic tanh see here. We are using the sigmoid activation function We will squash the weighted sum by using Sigma square It means we will pass that, you know weighted sum in that, you know activation function I will show you how we will do it. See now. I am going to write the Mathematical steps for the forward propagation. What we are going to do is forward propagation So for forward propagation, what is the net?
Weight coming towards the load. H1. You can see the architecture here It is w1 into i1 plus w2 into I 2 plus B 1 into 1 See you can see the architecture. It's very simple the connections coming towards h1. It should be you know, it is W1 into 1 plus W 2 into I 2 Plus B 1 into 1 Then we will calculate the values weights and in all these things it's represented here so you can calculate it with P 0.15 into 0.05 plus 0.2 into 0.1 of plus
0.35 into 1. See I told you know Bye as always we take it as one it's late. We need to multiply it. That's five So this when you calculate you will get it as of zero point three seven seven five So I I will suggest you also write all these steps along with this then you will get you will It will be easy for you. Please start writing along with me you will understand how this forward propagation Backward propagation walk. It's really easy. So this is the net You know
Wait, or we can cut we can call it as net h1 so we calculate the weighted sum or the net weight coming towards the lower edge for what is the second process the Artificial neuron or perceptron will do it will squash it using a perm, you know, you know Activation function here. The activation function is sigmoid function So, you know it it is, you know the sigmoid function it is some it is given by this is the formula for sigmoid function 1 by 1 plus e raised to minus X This is the formula for the sigmoid function. And even I have calculated the derivative of that and finally when I calculate the derivative of a sigmoid function, I got it as D Sigma by DX is equal to Sigma into 1 minus Sigma One second. I will see
It is you know when I calculate the derivative Sigma 1 minus Sigma This we have done it the previous video, please watch it because this equation we are going to use it This is really important this equation and this equation both the equations. We are going to use it in this explanation So this is the now I know net h1. Now we are going to scratch it using this function C We will pass instead of X. We will pass this net. H1. See this is the in this architecture
This is the total weight coming to us H on inside each one. We have the active function the activation function Represents the state of a node it introduces Non-linearity inside the neural network. It's really important This activation functions. So now we are inside this, you know node h1 The weighted sum is crashed it by using the activation function That's what happening in the next step
so I am going to tell you even in your by now or biological neuron right based on the circumstance based on your Emotions what see the what all the neurons will be triggered. There are trillions of neurons in your brain So that depends on some state of the neuron in the same way What already you programmed in your neuron in the same way in our artificial neuron as well? There is a state that is represented by activation function this introduces
Non-linearity. Well they in inside you are you know a neural network the if you if I talk about sigmoid function its value ranges from 0 to 1 see its value ranges from 0 to 1 for sigmoid function any value you can get in between 0 and 1 for Hyperbolic, tanh its value ranges from minus 1 to 1. So it's it's introduces Non-linearity inside the neural network. Ok fine. So you calculated the net h1? now I am going to scratch it using the
Artificial neural a sorry from this sub sigmoid function so you can see it here So the that is the after scratching it you will get the output of HR so the net action represents the weighted sum now the output of each one should be I am calculating them out H 1 Out H 1 should be 1 by 1 Plus e raise to minus X instead of X it should be netted I Told you it is net H 1 So what we got it is you can see it in the oh, no your be calculated it so it is minus 0.37 seventy-five. This is what you ve got it when you calculate it You will get zero point five nine three to six Triple nine - this is the outlet shown you are getting it see the same process you can repeat for
Out H 2 as well So the same process you can repeat for H 2 you can calculate net H to the now take whatever I have told you just now you can repeat so then you will get the you know The out H 2 You will get it as when you repeat the same process. You will get the out H to us out H 2 is equal to Zero point I know 5 9 Out H 2 you will get it as
0.596 Doublet you can calculate when you follow the steps you know now you write it along with this video you start writing this but After this video you can you know calculate how this how did you do is coming so you will get more idea so I have you know calculated with the weighted sum net H 1 and Out H 1 Netta 2 you will calculate and you will get the amp H 2 as well So you got that aspect So these two things you got it now, I am going to calculate the net H 1. Sorry net Oh one and we will calculate the out over so the network should be a
Net one you can see it in the figure I am going to calculate the net war it is the weighted sum coming towards you know, the Node or it should be you can see it here W Phi into out h1 So the weight into the output of that h1, that's fine So W 5 into out h1 plus, you know W 6 into out h2 Be two into one Once again next oh one is equal to w 5e two out. H1 Plus w six in the outer edge though. You could see the friggin plus B 2 into 1 So that's what I am going to calculate So netwo 1 is equal to you can write it as w 5 Hindu out H 1 plus W 6 into out
Picture 2 plus B 2 into 1. So this is what you are going to calculate Then you will get it as you can see it. Here it is 0.4 into or the outer CH 1 we calculated previously. It is zero point 5 9 3 2 6 2 prone I'm - so all these values we are W 6 is there it is? 0.45 your you know, B, 2 is 0.6 so all these values we will substitute then you can write it as 0 point 4 into 5 is 0 point 5 9 Are 3 to 6? triple 9 to this we got it previously plus 0.45 into Zero point 5 9 6
8 8 out it should also we will get it previously four three seven eight plus zero Point 6 into 1 that is equal to we will get it as one point One zero five nine zero five nine six seven, this is the net one So what is the next step every? Perceptron every artificial neuron, you will calculate the weighted sum and scratch it using You know, you are, you know a sigmoid function. So the this is the knit one So the outer one should be the outer one. See we I am going to calculate the outer one So the outer one should be out. Oh one is equal to 1 by 1 plus e raised to minus Net 201. So instead of 1 by 1 plus e raise to minus X We will calculate the net or what that's what because inside this, you know
Newtman nord, whatever input it's coming. That is the X. So that is net wall 1 by 1 plus e raise to minus Net1 so it would be 1 by 1 plus e raise to minus We calculated it previously it is 1 point one zero five nine zero five nine Six seven this we calculated when you substitute this you will get it as zero point Seven five one three six five zero seven, please write the steps along with me So this is the way you calculate the alcohol one You can repeat the same process and you can calculate out or two as well. You will get output to us out To T is equal to you will get it as you know zero point seven seven to nine to I Ate four six five. This is output
Now see we will get the output values for this neural network o 1 and O 2 Now what we will do inside the forward propagation So inside the forward propagation you save the forward propagation. See we got the output values o 1 and O 2 now We have the target value or the actual value. So the target value or actual value it is 0.01 and 0.99 by using the target value and the output value We will calculate the error see I told you about the cost function and error function see ah I told you about the cost function and error function so the you know The error function the formula I have given you is it is e is equal to I have to you previously Sigma of 1/2 into charges For - good target means the actual value output means our predicted value The whole square this is the error function or cost function so we can calculate
CV because the amino output value 401 we got out over and we got out ode to we have the target value 401 here you have the target value for woven and target value for poor two by using these you can Calculate the error 401 and error 402 by using this formula. We are calculating the error for Output node. Oh one and the output node or two so the error for output output node or one should be the same formula we are using it would be e 0 1 is equal to half in dual of the target value, you know it is
0.01 here 0.01 - up the output value 401 We just now we calculated it is zero point seven five four one three six Five five there is no space. I am writing it here zero seven the holds 5 This is the error for the node over the output node 1 or Represents output o one it is when you calculate you will get it as zero point two seven Four eight one one zero eight three This is the error for the out First out with node in the same way the same formula you can use it for the you know
Second node when you complete the error for the the same process You can repeat when you calculate the error for the second node. You will get the error as E or to the output node to you will get it as you know zero point zero two three Five six double zero two six. This is the Error for the second node. So the total error will be so this is the sum of these two is zero one plus e 0 2 and This will be you need to add these two zero point two seven four eight one one zero eight three plus zero
point zero two three five six Zero zero two six you can write along with me Then you will get it then when you add these two you will get the total error as an you know it is equal to zero point two nine eight three Seven double one zero nine. This is the total error So in the forward propagation, we calculate the total error So this is all about you know a forward propagation. So in the next video, we will be discussing about the Backward propagation. Thanks for watching

Ask anything
We've read this whole study set, so questions about it get the best answers.