Hello.
Welcome back.
Let's continue.
So we're going to write the function for learning or optimizing as some would call it.
I'm going to save this and continue from a new one.
Call this number five and then I'm going to come down here and create a new function called Len.
I said def Len and this function is going to okay this word is taking
I'll say and Len
Oh no sorry.
We can use Len.
Yeah.
Sorry about that because he was blue.
I thought it was a reserved key word in python.
But it's not.
Okay.
So he's going to take a number of arguments we're going to pass that weight the buyers the training
data the labels we're going to pass number of iterations as well.
And then we can pass the learning rate
yes and then that's fine.
So yeah I'm going to create a list here an empty list called cost
and then I can open them the loop for learning I'll see for i in range.
She can guess
number of iterations
then we can call our product to function propagation over here or call this.
And then remember propagation is going to return the gradients and the cost.
So you can't simply come here and see gradients Cost.
Cost is different from costs.
Cost this plural to singular cause propagation then I'm going to pass the parameters required W B X
and Y like this.
And then once we've computed a cost for so remember each example we compute that cost and then we add
it here.
So I'm going to append this to our costs list.
This costs costs plural.
I'm going to append costs that append this singular cost like this.
Okay.
Once that is done we have to update the wait.
I'll come here and see it W equals W minus.
We apply the lending rate
multiplied by T W and then we update the bias as well.
B equals B minus.
We apply the Lenin rate
and then be like this.
Okay.
So we can print the cost.
We can say if it if it runs for let's say 50 times print that cost so I can see if if by percentage
hobo there's a percentage 50 because you then I'm going to print the cost print
stuff.
Iteration percentage I don't percentage F
and I'm simply going to pass the value here and the cost here.
Like this.
Right
and um we can store the parameters in the key valued pair in a dictionary and then return the parameters
as well as the gradient after Len and after the optimization process.
So I'm going to create paradigms here and store the WNBA values course we need then we would need them
later firearms.
And then I'll say w w and then B B right.
And then the gradient reds
Oh c d w w
DP DP and I'm going to return parameters and gradients return but Rams reds and also costs.
Right.
Okay.
So this is it.
This is our function to learn the next lesson we going to write the function to help us predict.
Yeah.
So this order is for this lesson if you have any questions just let me know.
I'll see you later.