1
00:00:00,360 --> 00:00:00,720
Hello.

2
00:00:00,750 --> 00:00:01,380
Welcome back.

3
00:00:01,380 --> 00:00:02,070
Let's continue.

4
00:00:02,100 --> 00:00:07,830
So we're going to write the function for learning or optimizing as some would call it.

5
00:00:07,830 --> 00:00:11,530
I'm going to save this and continue from a new one.

6
00:00:11,550 --> 00:00:19,270
Call this number five and then I'm going to come down here and create a new function called Len.

7
00:00:19,730 --> 00:00:27,620
I said def Len and this function is going to okay this word is taking

8
00:00:32,830 --> 00:00:34,000
I'll say and Len

9
00:00:37,590 --> 00:00:38,940
Oh no sorry.

10
00:00:39,280 --> 00:00:40,120
We can use Len.

11
00:00:40,150 --> 00:00:40,410
Yeah.

12
00:00:40,630 --> 00:00:42,520
Sorry about that because he was blue.

13
00:00:42,520 --> 00:00:45,060
I thought it was a reserved key word in python.

14
00:00:45,100 --> 00:00:46,050
But it's not.

15
00:00:46,610 --> 00:00:46,980
Okay.

16
00:00:47,020 --> 00:00:52,450
So he's going to take a number of arguments we're going to pass that weight the buyers the training

17
00:00:52,480 --> 00:01:01,240
data the labels we're going to pass number of iterations as well.

18
00:01:01,240 --> 00:01:03,850
And then we can pass the learning rate

19
00:01:06,800 --> 00:01:08,620
yes and then that's fine.

20
00:01:09,340 --> 00:01:16,810
So yeah I'm going to create a list here an empty list called cost

21
00:01:20,160 --> 00:01:27,280
and then I can open them the loop for learning I'll see for i in range.

22
00:01:29,020 --> 00:01:29,950
She can guess

23
00:01:32,900 --> 00:01:34,250
number of iterations

24
00:01:46,900 --> 00:01:52,810
then we can call our product to function propagation over here or call this.

25
00:01:53,470 --> 00:01:57,600
And then remember propagation is going to return the gradients and the cost.

26
00:01:58,210 --> 00:02:08,060
So you can't simply come here and see gradients Cost.

27
00:02:08,530 --> 00:02:10,760
Cost is different from costs.

28
00:02:10,830 --> 00:02:22,210
Cost this plural to singular cause propagation then I'm going to pass the parameters required W B X

29
00:02:22,330 --> 00:02:24,200
and Y like this.

30
00:02:24,760 --> 00:02:32,150
And then once we've computed a cost for so remember each example we compute that cost and then we add

31
00:02:32,180 --> 00:02:32,700
it here.

32
00:02:33,280 --> 00:02:37,920
So I'm going to append this to our costs list.

33
00:02:37,930 --> 00:02:40,840
This costs costs plural.

34
00:02:41,020 --> 00:02:46,830
I'm going to append costs that append this singular cost like this.

35
00:02:47,680 --> 00:02:48,540
Okay.

36
00:02:48,730 --> 00:02:52,820
Once that is done we have to update the wait.

37
00:02:52,830 --> 00:02:57,430
I'll come here and see it W equals W minus.

38
00:02:57,670 --> 00:02:59,140
We apply the lending rate

39
00:03:02,200 --> 00:03:07,780
multiplied by T W and then we update the bias as well.

40
00:03:07,870 --> 00:03:13,790
B equals B minus.

41
00:03:13,990 --> 00:03:15,370
We apply the Lenin rate

42
00:03:19,800 --> 00:03:23,610
and then be like this.

43
00:03:24,090 --> 00:03:24,510
Okay.

44
00:03:27,820 --> 00:03:29,110
So we can print the cost.

45
00:03:29,110 --> 00:03:39,970
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

46
00:03:40,230 --> 00:03:47,050
hobo there's a percentage 50 because you then I'm going to print the cost print

47
00:03:53,630 --> 00:03:54,110
stuff.

48
00:03:54,130 --> 00:04:00,250
Iteration percentage I don't percentage F

49
00:04:06,290 --> 00:04:12,880
and I'm simply going to pass the value here and the cost here.

50
00:04:12,880 --> 00:04:14,760
Like this.

51
00:04:14,760 --> 00:04:15,160
Right

52
00:04:20,500 --> 00:04:27,730
and um we can store the parameters in the key valued pair in a dictionary and then return the parameters

53
00:04:27,820 --> 00:04:34,080
as well as the gradient after Len and after the optimization process.

54
00:04:34,180 --> 00:04:43,060
So I'm going to create paradigms here and store the WNBA values course we need then we would need them

55
00:04:43,060 --> 00:04:46,370
later firearms.

56
00:04:46,510 --> 00:04:59,520
And then I'll say w w and then B B right.

57
00:04:59,620 --> 00:05:02,140
And then the gradient reds

58
00:05:06,520 --> 00:05:10,480
Oh c d w w

59
00:05:13,330 --> 00:05:29,120
DP DP and I'm going to return parameters and gradients return but Rams reds and also costs.

60
00:05:29,120 --> 00:05:30,960
Right.

61
00:05:31,740 --> 00:05:33,450
Okay.

62
00:05:34,330 --> 00:05:35,410
So this is it.

63
00:05:35,410 --> 00:05:42,670
This is our function to learn the next lesson we going to write the function to help us predict.

64
00:05:43,560 --> 00:05:44,570
Yeah.

65
00:05:44,890 --> 00:05:47,700
So this order is for this lesson if you have any questions just let me know.

66
00:05:47,710 --> 00:05:48,490
I'll see you later.
