1
00:00:00,810 --> 00:00:01,170
Hello.

2
00:00:01,500 --> 00:00:08,010
So let's see how to build the single input multiple output neural network.

3
00:00:08,070 --> 00:00:11,550
I'm going to make a copy of the last project or paste it over here

4
00:00:24,880 --> 00:00:26,080
just a single in

5
00:00:29,530 --> 00:00:30,580
motorboat out

6
00:00:33,430 --> 00:00:34,350
and then I'll open it

7
00:00:39,530 --> 00:00:40,550
right.

8
00:00:40,610 --> 00:00:43,680
So let's go to our neural network stasis file.

9
00:00:43,970 --> 00:00:48,600
So we're going to create a new function known as the single input multiple output.

10
00:00:48,970 --> 00:00:52,030
But let's take a look at the neural network again.

11
00:00:52,580 --> 00:00:53,640
Is what it looks like.

12
00:00:53,660 --> 00:00:54,910
The input is single.

13
00:00:55,550 --> 00:00:59,300
Let's say we have sad end from sad.

14
00:00:59,330 --> 00:01:04,040
We want to derive the temperature the humidity and the air quality.

15
00:01:04,040 --> 00:01:06,760
So all we have is sad and.

16
00:01:06,780 --> 00:01:07,580
Wait.

17
00:01:07,640 --> 00:01:15,200
That would help us derive the temperature the other weight that would help us derive humidity and a

18
00:01:15,200 --> 00:01:18,980
third way to die would help us derive the air quality.

19
00:01:18,980 --> 00:01:24,240
And over here we said we have to do what is known as element wise multiply meaning.

20
00:01:24,500 --> 00:01:26,990
We take these color value which is sad.

21
00:01:27,000 --> 00:01:28,340
This single number.

22
00:01:28,610 --> 00:01:37,850
And then we multiply it by we we sort of multiply it by a vector of weight cause the weight is going

23
00:01:37,850 --> 00:01:40,500
to be an array an array of three elements.

24
00:01:40,570 --> 00:01:44,480
So we multiply this same number by each member this number.

25
00:01:44,480 --> 00:01:48,390
This single number by each member of the array essentially.

26
00:01:48,390 --> 00:01:50,000
And this is what is shown here.

27
00:01:50,090 --> 00:01:56,510
Saad multiplied by which one side multiplied by way two on the side multiplied by weight three.

28
00:01:56,510 --> 00:02:01,670
So what I would advise you do is you post a video and try to implement this on your own.

29
00:02:01,670 --> 00:02:08,660
And once you've done it you can sort of play the video again and see us we do it together.

30
00:02:09,110 --> 00:02:10,510
Right.

31
00:02:10,670 --> 00:02:11,570
Welcome back.

32
00:02:11,570 --> 00:02:13,250
Then I'm going to come over here.

33
00:02:13,280 --> 00:02:18,470
I'm going to create a function known as element y's multiply and then I'm going to wrap a new function

34
00:02:18,470 --> 00:02:21,890
around it for readability.

35
00:02:22,560 --> 00:02:23,390
So I'll see void

36
00:02:27,350 --> 00:02:34,460
and I'll call this element y's multiply.

37
00:02:34,970 --> 00:02:40,670
This function is going to take it's going to take four parameters.

38
00:02:40,910 --> 00:02:46,580
The first parameter is going to be the input which is a scale of value a single number.

39
00:02:46,800 --> 00:02:50,480
And it's of type double I'm going to call this input scalar

40
00:02:58,370 --> 00:03:07,000
The second argument is green to be a pointer to the weight vector or a pointer to the weight one dimensional

41
00:03:07,050 --> 00:03:07,360
rate.

42
00:03:07,370 --> 00:03:18,080
Whenever I mention a vector or just think of a one dimensional array so see weight vector here.

43
00:03:18,470 --> 00:03:23,740
The third argument is going to be a pointer to a one dimensional array to store the output.

44
00:03:24,290 --> 00:03:25,910
So call this output vector

45
00:03:31,880 --> 00:03:37,280
and then the output vector length is going to be the same as the weight vector length.

46
00:03:37,760 --> 00:03:46,340
So I'm going to create a new variable here which is a new argument here which is going to be the length

47
00:03:46,340 --> 00:03:47,450
of the vector.

48
00:03:47,510 --> 00:03:56,450
So call this vector length like this open and then close.

49
00:03:56,640 --> 00:03:57,160
Right.

50
00:03:57,160 --> 00:04:03,180
Very simple very straightforward and we can implement it just like we saw in the theoretical class.

51
00:04:03,490 --> 00:04:05,030
We can use a for loop to do the.

52
00:04:05,170 --> 00:04:10,000
We can just use a for loop to iterate over each item in the vector.

53
00:04:11,280 --> 00:04:23,470
So say for int i 0 0 is less than vector length I plus plus.

54
00:04:23,470 --> 00:04:30,070
And what we want to do is output vector index i equals inputs color

55
00:04:34,370 --> 00:04:40,430
multiply by weight vector index I as simple as this.

56
00:04:40,430 --> 00:04:40,820
Right.

57
00:04:40,820 --> 00:04:43,940
So that's the it element y's multiplication.

58
00:04:44,090 --> 00:04:52,550
Once we've done this we can wrap it around a we can wrap in new function around it by saying void single

59
00:04:52,550 --> 00:04:53,060
input

60
00:04:56,950 --> 00:05:00,190
underscore multiple output n n

61
00:05:08,650 --> 00:05:12,850
and this is going to take exactly the same argument as this

62
00:05:19,910 --> 00:05:20,410
right.

63
00:05:31,120 --> 00:05:37,920
Open Close and all we have to do is call our function the element y's function.

64
00:05:38,280 --> 00:05:46,970
Over here you see element wise multiple and the first argument is the input scalar.

65
00:05:47,470 --> 00:05:56,250
The second argument is the weight vector.

66
00:05:56,540 --> 00:06:01,760
The third argument is the output vector.

67
00:06:02,030 --> 00:06:06,910
The last I comment which is the fourth argument is the vector length.

68
00:06:06,930 --> 00:06:10,630
Simple as this we can expose our function.

69
00:06:11,420 --> 00:06:12,500
We can expose this one.

70
00:06:12,500 --> 00:06:19,630
So you see we only expose these functions these ones aren't exposed element wise it's not exposed weighted

71
00:06:19,640 --> 00:06:20,790
sum it's not exposed.

72
00:06:20,790 --> 00:06:24,590
Just the neural network functions are exposed.

73
00:06:24,650 --> 00:06:33,470
So I'm going to copy this and put it over here and then some call on here we can go to our main file

74
00:06:33,470 --> 00:06:36,400
and test it out.

75
00:06:36,630 --> 00:06:38,810
I'm going to clean everything from here

76
00:06:42,870 --> 00:06:44,490
right.

77
00:06:44,580 --> 00:06:45,230
Right.

78
00:06:45,410 --> 00:06:48,220
So we can say okay we have.

79
00:06:48,350 --> 00:06:50,160
We can define sad.

80
00:06:50,450 --> 00:06:57,100
I'm gonna see sad is zero point nine.

81
00:06:57,100 --> 00:06:57,480
Right.

82
00:06:57,580 --> 00:07:01,610
I'm going to give a symbolic name to zero point nine to me inside.

83
00:07:01,720 --> 00:07:04,780
Okay this is just an example like I say.

84
00:07:04,780 --> 00:07:10,960
Like I said earlier I'm using random numbers here I'll say define temperature

85
00:07:16,250 --> 00:07:19,130
I'm just going to create a symbolic name for the indices.

86
00:07:19,130 --> 00:07:24,590
So I would just say perhaps temperature

87
00:07:28,190 --> 00:07:34,120
prediction index cause we know temperature indexes at index 1 course in the input vector.

88
00:07:34,160 --> 00:07:35,600
The first one is temperature.

89
00:07:36,290 --> 00:07:37,700
So let's just maintain that

90
00:07:43,870 --> 00:07:46,270
index zero I mean temperature is at index you

91
00:07:52,990 --> 00:07:54,670
humidity prediction index

92
00:08:18,340 --> 00:08:22,990
air quality is at index 2 Okay.

93
00:08:23,180 --> 00:08:30,770
And we can define the length of the output which is the same as the vector land because the output land

94
00:08:31,190 --> 00:08:40,990
is equal to the weight linked to the length of the weight.

95
00:08:41,000 --> 00:08:45,910
So we can create a vector here to hold a predicted resort.

96
00:08:46,030 --> 00:08:46,790
I'll say double

97
00:08:49,420 --> 00:08:56,050
predicted resort and it's of size three right.

98
00:08:57,620 --> 00:09:06,230
And we can sort of create let's say we have our weight vector as great a weight vector for example

99
00:09:12,690 --> 00:09:19,710
and the first weight is 20 minus twenty second one could be ninety five let's just say these are weight

100
00:09:19,920 --> 00:09:28,240
for some strange reason these are the weights and the first weight here yes what temperature the second

101
00:09:28,270 --> 00:09:30,360
wait is for humidity.

102
00:09:30,790 --> 00:09:34,100
And this one is for air quality.

103
00:09:34,120 --> 00:09:35,620
I'll show you again

104
00:09:39,610 --> 00:09:40,690
this on your network.

105
00:09:40,690 --> 00:09:45,910
We've got way too one way too with three weight one belongs to temperature way too for humidity with

106
00:09:45,910 --> 00:09:48,940
three for air quality right.

107
00:09:53,000 --> 00:09:54,520
OK so that's it.

108
00:09:54,670 --> 00:09:57,860
Now we can call our function.

109
00:09:58,150 --> 00:10:05,930
I can come over here and see a single input multiple output neural network.

110
00:10:05,950 --> 00:10:09,700
The first argument is the input scalar which is sad.

111
00:10:09,880 --> 00:10:12,600
I simply need to pass that over here.

112
00:10:12,640 --> 00:10:16,920
The second argument is the weight vector.

113
00:10:17,500 --> 00:10:18,610
I'll just make this plural

114
00:10:21,640 --> 00:10:27,700
the third argument is the output vector predicted resort.

115
00:10:27,790 --> 00:10:34,590
The last argument is the vector lent I'll just use output length here.

116
00:10:34,810 --> 00:10:35,410
Right.

117
00:10:35,470 --> 00:10:38,210
So this will predict the resort.

118
00:10:38,230 --> 00:10:43,040
We can print out the resort to zero.

119
00:10:43,420 --> 00:10:44,380
So say print f

120
00:10:51,680 --> 00:10:53,000
predicted temperature

121
00:11:00,840 --> 00:11:11,330
is percentage F R and then n and then we can go to our predicted results.

122
00:11:11,380 --> 00:11:12,630
I read this array here.

123
00:11:12,630 --> 00:11:18,900
We know the first index which is index zero represents temperature so I can just pass temperature index

124
00:11:18,900 --> 00:11:28,260
here just for readability sake I've created this this naming convention right.

125
00:11:29,270 --> 00:11:33,260
And we can copy this and do the same for humidity and air quality

126
00:11:40,690 --> 00:11:42,410
the humidity index is this

127
00:11:49,250 --> 00:11:51,600
and we can do it once more for quality

128
00:12:05,990 --> 00:12:06,590
right.

129
00:12:06,650 --> 00:12:08,370
Let's build and see what we have.

130
00:12:08,390 --> 00:12:09,530
Click over here to build

131
00:12:12,570 --> 00:12:15,320
Click here to download onto the board.

132
00:12:15,660 --> 00:12:16,680
Let's see Terra term

133
00:12:22,970 --> 00:12:25,550
Oh reset my board.

134
00:12:25,550 --> 00:12:28,950
Okay so there's the temperature prediction.

135
00:12:29,060 --> 00:12:35,300
So basically what our neural network is saying is if you're sad given the weight then the temperature

136
00:12:35,300 --> 00:12:39,030
is minus 18 degrees Celsius the humidity is 85.

137
00:12:39,620 --> 00:12:43,490
The air quality is one 80 right.

138
00:12:43,550 --> 00:12:47,840
So there are ways of measuring air quality as the air quality index.

139
00:12:47,840 --> 00:12:51,140
So 180 is it s not so good.

140
00:12:51,380 --> 00:12:58,510
The World Health Organization recommends air quality should be a think below 50 or a hundred.

141
00:12:58,520 --> 00:13:01,880
I don't quite remember that number but one eighty certainly not good.

142
00:13:01,880 --> 00:13:07,010
And again we are using just random numbers and those of you who are not familiar with call your vision

143
00:13:07,890 --> 00:13:09,600
um you can actually view.

144
00:13:09,710 --> 00:13:12,920
You can view all of the resorts without a zero plot.

145
00:13:12,950 --> 00:13:21,020
Just that you wouldn't have sentences you would sort of not without the um the terror term you could

146
00:13:21,020 --> 00:13:25,340
view the resort by just put in the array in the watch window.

147
00:13:25,340 --> 00:13:26,750
This is not zero plot.

148
00:13:26,780 --> 00:13:31,080
This is just a zero software zero.

149
00:13:31,190 --> 00:13:36,090
I said zero plot because I was using arduino the other day in that Reno has the zero plotter.

150
00:13:36,730 --> 00:13:42,740
Um so we can simply say I came I clicked over here had to come to debug view and you can double click

151
00:13:42,740 --> 00:13:50,750
on this global variable which is on read and go to UT to watch window out to watch window one and you

152
00:13:50,750 --> 00:14:01,280
can expand it and you see we have index 0 1 2 here and we click here to run that's going to see a clean

153
00:14:01,280 --> 00:14:08,120
this well this has run again but as you can see the values here are the same

154
00:14:11,180 --> 00:14:15,290
the values here are the same as this and I was zero plot is actually.

155
00:14:16,210 --> 00:14:16,550
Okay.

156
00:14:16,580 --> 00:14:17,370
It's fine.

157
00:14:17,370 --> 00:14:24,140
It s print it accurately it s eighty five point five it s five point five one eighty point nine one

158
00:14:24,140 --> 00:14:24,910
eighty point nine.

159
00:14:25,280 --> 00:14:30,770
So you can view it in the debugger as well in a way this all the rest and I'll see you later.

160
00:14:30,770 --> 00:14:31,450
Have a nice day.
