1
00:00:00,810 --> 00:00:01,240
Hello.

2
00:00:01,260 --> 00:00:02,200
Welcome back.

3
00:00:02,220 --> 00:00:05,820
So let's see how to randomly initialize our weights.

4
00:00:05,910 --> 00:00:14,320
So I'm gonna make a copy of the last project and then I should mention that over here we gonna use this

5
00:00:14,320 --> 00:00:24,470
and uh we're gonna use a sort of random number generator but ordinarily or I should say wait till I'm

6
00:00:24,480 --> 00:00:26,760
type this first.

7
00:00:26,790 --> 00:00:32,850
Ideally we should use the random number generator of our microcontroller or so a microcontroller comes

8
00:00:32,850 --> 00:00:40,740
with a hardware random number generator and that is much more precise compared to using the C standard

9
00:00:40,740 --> 00:00:43,200
library round function.

10
00:00:43,350 --> 00:00:49,040
So later on we want to see how to use the hardware random number generator on the microcontroller.

11
00:00:49,140 --> 00:00:55,020
But for this let's just try these thunder to see um run function.

12
00:00:56,280 --> 00:01:00,240
So we said Um let's see let's see this of architecture.

13
00:01:00,240 --> 00:01:05,650
So we piece these sign ups over here sign up so we send up someone.

14
00:01:06,280 --> 00:01:08,430
Basically this is a way to matrix.

15
00:01:08,430 --> 00:01:18,060
This is a matrix a matrix of weights containing the weights and this input here interact with the weights

16
00:01:18,240 --> 00:01:24,630
within this and up 0 to produce the output for this layer and then we'll take this and its Iraq to which

17
00:01:24,690 --> 00:01:31,890
this other weights to produce this sort of output and to start off in machine then in the weights are

18
00:01:31,890 --> 00:01:38,340
often initialized to random values rather than 0 we initialize the weights to random values so we would

19
00:01:38,340 --> 00:01:44,640
have to find a way to always have a random number generator to initialize it for us sort of to keep

20
00:01:44,640 --> 00:01:51,660
the ball in the air like a sports like volley someone has to throw the ball in the air and then a player

21
00:01:51,660 --> 00:01:54,060
that gets it first you stop playing with it.

22
00:01:54,060 --> 00:02:00,390
So the initialization is like getting the Portlandia so you start somewhere randomly and then the learning

23
00:02:00,390 --> 00:02:04,880
begins from the wrong random point right.

24
00:02:05,480 --> 00:02:06,060
Um yeah.

25
00:02:06,180 --> 00:02:10,060
So I'm gonna go to the simple neural network don't see.

26
00:02:11,600 --> 00:02:20,670
And I'm gonna come over here which show creates a function called the um the way to random initialization.

27
00:02:20,670 --> 00:02:25,790
And like I said this will be improved later on when we use the hardware.

28
00:02:26,280 --> 00:02:34,010
This over here we are focusing on understanding not efficiency in these initial sections.

29
00:02:34,050 --> 00:02:35,920
The focus is on understanding.

30
00:02:36,390 --> 00:02:37,310
Right.

31
00:02:37,380 --> 00:02:38,640
So I'm gonna say Wait.

32
00:02:39,960 --> 00:02:48,210
Um random initialization does a descriptive name which random initialization.

33
00:02:48,210 --> 00:02:53,640
And this is going to take a number of factors meant to be precise.

34
00:02:53,670 --> 00:02:55,410
It's gonna take three argument.

35
00:02:55,410 --> 00:03:04,400
The first one is going to be the hidden layer lend the input lint and the um the weight matrix.

36
00:03:04,680 --> 00:03:06,830
But this implies one is hidden layer.

37
00:03:06,870 --> 00:03:07,740
Right.

38
00:03:08,310 --> 00:03:09,470
So I suppose.

39
00:03:09,600 --> 00:03:09,960
Yeah.

40
00:03:09,990 --> 00:03:12,050
This the this the hidden layer.

41
00:03:13,500 --> 00:03:14,520
So when we get here.

42
00:03:15,300 --> 00:03:17,950
Okay let's take a step by step sorry about that.

43
00:03:18,060 --> 00:03:23,390
I'm gonna come over here and see you into 32 unescorted T.

44
00:03:24,150 --> 00:03:24,900
He didn't land

45
00:03:29,990 --> 00:03:33,690
and this means the number of notes in the hidden layer and then you in that to

46
00:03:38,030 --> 00:03:39,500
and then input lent

47
00:03:45,450 --> 00:03:55,180
and then a matrix to store the the output weight that will be generated.

48
00:03:55,180 --> 00:04:03,620
So say double weight matrix and the size of this number of roses.

49
00:04:03,700 --> 00:04:11,670
He didn't length number of columns as inputs land like this.

50
00:04:12,550 --> 00:04:13,160
Right.

51
00:04:13,180 --> 00:04:15,030
So open and close over here

52
00:04:21,600 --> 00:04:25,230
okay.

53
00:04:25,440 --> 00:04:36,870
And when I put a global variable here I see a double T on the score around and I'm gonna seed it

54
00:04:43,540 --> 00:04:47,420
with a comment seed random number generator

55
00:04:50,980 --> 00:04:55,040
No not C S front I should always take him into

56
00:05:02,160 --> 00:05:08,230
it with one or whatever the reason we have in this red mark is because we've not included DC standard

57
00:05:08,230 --> 00:05:23,500
library so come over here include STV end this Tedy lib sorry that H and should be find a typo fixed.

58
00:05:23,570 --> 00:05:25,160
Good right.

59
00:05:25,750 --> 00:05:31,050
So once this is done we can call our function or we can complete our function.

60
00:05:31,320 --> 00:05:33,160
So I'm simply going to say

61
00:05:36,670 --> 00:05:38,530
for int i equals zero.

62
00:05:38,610 --> 00:05:46,250
I it's less than the number of rows which is the hidden Len I plus plus open and close.

63
00:05:46,770 --> 00:05:48,670
And then for int

64
00:05:52,680 --> 00:06:01,590
for int j equals you j is less than number of columns which is input Len

65
00:06:04,860 --> 00:06:10,050
J plus plus open and close and over here

66
00:06:14,050 --> 00:06:14,870
I generate

67
00:06:19,440 --> 00:06:20,520
random numbers

68
00:06:23,910 --> 00:06:26,390
between 0 and 1.

69
00:06:27,330 --> 00:06:34,910
So come over here see a different global variable equals round

70
00:06:37,980 --> 00:06:39,000
percentage 10

71
00:06:42,200 --> 00:06:48,470
then dethroned because divided by 10.

72
00:06:50,810 --> 00:06:51,380
And then

73
00:06:55,630 --> 00:07:00,550
I simply say wait wait.

74
00:07:00,560 --> 00:07:03,140
Matrix index.

75
00:07:03,180 --> 00:07:03,590
Hi

76
00:07:07,340 --> 00:07:10,690
next J.

77
00:07:11,330 --> 00:07:11,700
Right

78
00:07:15,430 --> 00:07:20,710
and um this doesn't have to be global.

79
00:07:20,710 --> 00:07:21,490
Bring it in here.

80
00:07:38,090 --> 00:07:38,610
Sure.

81
00:07:38,630 --> 00:07:40,160
Weather across the front.

82
00:07:41,780 --> 00:07:42,200
Okay.

83
00:07:42,240 --> 00:07:43,720
So I'm gonna grab this.

84
00:07:43,720 --> 00:07:53,250
The prototype gonna put over here the head of a put a semicolon here and we can go into our main the

85
00:07:53,240 --> 00:07:55,670
c file to test it out.

86
00:07:56,510 --> 00:08:05,160
We can start off by wiping off the current content in the main function.

87
00:08:05,630 --> 00:08:09,400
So this what we have we have our data already here.

88
00:08:09,890 --> 00:08:17,710
So I'm simply going to create a number of variables.

89
00:08:17,810 --> 00:08:18,870
I'm gonna come over here.

90
00:08:19,040 --> 00:08:21,000
Let's test a simple test.

91
00:08:21,110 --> 00:08:21,860
We'll see a double

92
00:08:26,800 --> 00:08:27,880
um.

93
00:08:28,070 --> 00:08:31,290
Let's see the names we gave it to the names you gave them.

94
00:08:31,370 --> 00:08:35,090
This is S N zero s and one s and for sign ups.

95
00:08:35,530 --> 00:08:38,140
So I'm gonna say s and I'm 0.

96
00:08:38,180 --> 00:08:40,000
How about a comment first.

97
00:08:43,320 --> 00:08:48,320
So this is input layer 2 hidden layer

98
00:08:52,560 --> 00:08:57,170
which matrix after the gonna have another one.

99
00:09:00,460 --> 00:09:06,760
You didn't layer to pull layer where it.

100
00:09:06,770 --> 00:09:09,140
Matrix right.

101
00:09:09,320 --> 00:09:10,150
So let's start with this.

102
00:09:10,160 --> 00:09:15,470
We're gonna create a buffer for it.

103
00:09:15,700 --> 00:09:28,610
So this is double S N zero and number of rows because number of rows because the number of hidden nodes

104
00:09:29,820 --> 00:09:37,320
number of columns equals number of features.

105
00:09:37,570 --> 00:09:38,980
Let's see how many hidden nodes.

106
00:09:39,250 --> 00:09:40,660
So we have three nodes here.

107
00:09:40,670 --> 00:09:42,280
Does the length and one note here.

108
00:09:43,120 --> 00:09:54,340
I'm gonna come over here include a defined statement I'll say a defined number of each I.D. mean in

109
00:09:54,340 --> 00:09:57,400
hidden nodes is three

110
00:09:59,920 --> 00:10:10,850
defined number of output nodes as one like this.

111
00:10:11,000 --> 00:10:20,920
So over here the size of this matrix is number of hidden nodes and number of features which is input

112
00:10:21,370 --> 00:10:22,210
number of inputs

113
00:10:26,480 --> 00:10:28,160
then this is synopsis.

114
00:10:28,430 --> 00:10:37,270
I was in OPs one double S and one the size of this is number of output nodes

115
00:10:41,290 --> 00:10:42,940
and number of hidden nodes

116
00:10:47,920 --> 00:10:48,370
right.

117
00:10:48,640 --> 00:10:53,620
So once this is done we can go and test this out by calling our function

118
00:10:58,330 --> 00:11:09,410
come way to random initialization and then we pass this length of hidden node number of hidden nodes.

119
00:11:09,420 --> 00:11:15,530
Then number of features and then we pass this into the synopsis zero matrix

120
00:11:20,260 --> 00:11:25,420
and then we initialize the other one which random initialization

121
00:11:30,070 --> 00:11:31,420
number of output nodes

122
00:11:35,120 --> 00:11:36,260
number of hidden notes.

123
00:11:39,630 --> 00:11:42,760
And put this in Snopes one.

124
00:11:42,870 --> 00:11:45,000
No we can go ahead and print the resort

125
00:11:53,560 --> 00:11:54,440
not sure.

126
00:11:54,460 --> 00:11:55,200
Wait.

127
00:11:55,410 --> 00:12:00,160
Use unless that loop over here.

128
00:12:03,970 --> 00:12:05,810
For int I Coursera.

129
00:12:06,250 --> 00:12:07,210
It's less than

130
00:12:13,470 --> 00:12:14,190
a number of

131
00:12:17,180 --> 00:12:17,530
no.

132
00:12:17,590 --> 00:12:18,280
Hit note.

133
00:12:21,840 --> 00:12:22,260
All right.

134
00:12:22,300 --> 00:12:26,670
Plus plus open inclusion and then

135
00:12:30,600 --> 00:12:37,640
J equals zero G is less than the number of features J.

136
00:12:37,650 --> 00:12:42,870
Plus plus open and close and what we want to do is

137
00:12:46,520 --> 00:12:47,100
print f

138
00:12:52,280 --> 00:13:03,290
percentage curve then shut up sheer index by index J and then we can print some new lines here.

139
00:13:03,290 --> 00:13:03,860
Print f

140
00:13:10,800 --> 00:13:12,190
n print another one

141
00:13:19,670 --> 00:13:20,420
right.

142
00:13:20,450 --> 00:13:29,060
Once this is done we can do the same for the second set ups which is set ups one and simply going to

143
00:13:29,060 --> 00:13:37,880
copy this and change it appropriately.

144
00:13:37,880 --> 00:13:49,910
This is an ops one and this becomes output notes and then this becomes the hidden nodes

145
00:13:53,290 --> 00:13:55,560
and is not one.

146
00:13:56,500 --> 00:14:00,620
Everything else remains the same right.

147
00:14:00,670 --> 00:14:04,380
So we can do that see what we have.

148
00:14:04,390 --> 00:14:09,130
Click over here to build Click here to download onto the board.

149
00:14:09,280 --> 00:14:10,480
Let's see to write a

150
00:14:17,060 --> 00:14:17,950
reset my board.

151
00:14:20,680 --> 00:14:22,320
And this is what we have.

152
00:14:22,540 --> 00:14:30,610
So we can see the way to matrix for forcing up 0 is 3 by 3 is 3 by 2 Sorry.

153
00:14:30,610 --> 00:14:41,740
Why must see cause we have two inputs to input 3 notes we have 2 inputs coming here 3 nodes.

154
00:14:41,890 --> 00:14:57,070
So we have 3 by 2 and the way to matrix for sign ups 1 is 1 by 3 because we have one node and then 3

155
00:14:57,100 --> 00:15:01,840
inputs entering into the single node but we should talk about dimensions later.

156
00:15:01,870 --> 00:15:09,550
Now just focus on understanding later on we have a section on how to take all of this from scratch again

157
00:15:09,950 --> 00:15:16,390
and in that section with formalized the ways in which you can tell the dimensions of the various layers

158
00:15:17,230 --> 00:15:24,580
and the matrices that they work with but thus far without case study this explanation should suffice.

159
00:15:24,580 --> 00:15:30,340
If you have any questions just send me a message on this or there is for this lesson and I'll see you

160
00:15:30,340 --> 00:15:30,850
later.

161
00:15:30,850 --> 00:15:31,530
Have a nice day.
