Hello.
Welcome back.
So let's sum this up underscore execute it.
I don't see implement all the functions that we needed to initialize and run our offerings.
There's this function here known as a I in it.
And this function is to create and initialized in your network and it's given explanations here.
All of these explanations were generated by the Cuban mix.
So you start off by this data structure to provide the inference for the activation slush working memory.
This the code that does that.
And then it creates an instance of the neural network and then it's initialized as the neural network.
This is known as the E I in it.
And this function is called You know what it makes cube in its function which should be somewhere here.
So our max cube a.
In its function is simply create chaos A.I. in its imposes activations here this argument this was a
I run looks like it takes a pointer to the input data and then another pointer to the output buffer.
And then over here it checks for input data.
It says if input data doesn't exist.
If it is false or output data is false or neural network is false.
Just return an error.
Ls initialize input and output buffer handles.
And it starts by initializing the batch size to 1 and then input data.
Here is a pointer to in data and then batch size 1 for outputs and then output data.
So this all of this generated by Cuba makes less to some final touches to the um the generated code
that we have over here over here.
You know what a AI in its function which is called by the cube and makes a init function.
I'm going to let's say Prince the arrow.
In case we get an arrow let's be able to print this 2 2 0 0 0 minutes.
So that we can know what's going on.
I'm going to say for instance if I were to type
it's not equal to zero none.
If that's the case then we can go ahead to print the arrow.
I'm simply going to say print f
over here.
I'll see Arrow or I'll use cup to Arrow shoot arrow and then print the type pass percentage T over here
and then the arrow could pass percentage D over here as well and then correct return New Line.
In no way I simply do a prototype and then I wrote a code like this.
Right.
So.
So we get to see the okay.
So let's take a look at our max cube a.
In its function.
Okay.
It's simply initialize as this and then cause a war in its function right.
Let's do the same for a what a run function.
If I hear we I'm gonna simplify this.
We're not going to be using in batch so I'll just take this off like this such that we simply do a run
and then we can check for a work error.
Print out the arrow as well.
K
I'll just simplify this a bit for you.
Rather than simply return the error could I'm going to send it to our serial monitor like we did earlier.
I'll see a print f
arrow
and then type of the arrow
pass percentage T over here and then the error could percentage T over here.
Now do comma erode the type error code like this.
Also I'm going to take this out here.
This check.
Um we always gonna have input data.
We always gonna have output data.
No one in your network you can it or you can keep it if you want and when to simplify to like this often
when data function is that you are using for the first time.
I preferred them you know looking as essential as possible so that you can be able to grasp the core
concept before other supplementary things are added to the function things like checking whether there
is in your network or there is input data or output buffer.
Those aren't part of the core.
This is the core function to run the neural network.
This over here to print the arrow can be deleted as well or you need to do is this over here right.
So this are what I run the a run is called by the is called by our E I O R E A process function and
I'm going to clean everything into a process all of this bits I'm going to clean it and we simply going
to call the E I run this function all of this snow.
It's not really required.
Um where is it a process function
okay starts from here.
So all we have all we have into a process function is simply a run right.
Like this
and we already
we already changed d d e I run we simplify the I run us.
Well
so um one other thing.
Yeah.
This function prototype.
We've changed it so we've got to update this function prototype.
So our main function the prototype for the AI process is this one over here.
It takes to document the input data and the outputs buffer.
So this is going to be the new prototype.
I'm gonna copy this from here and this will become the prototype of the def and this will become the
function definition.
So I'm gonna paste this over here and avoid here and the data type for this is a float pointer
and this is also a float pointer
and I'm going to clean this like this.
And um put this over here.
I'm going to update the DOT each file as well it's over here.
Gonna Replace this over here with this new one.
And then this and the cool on here.
Right.
So this the look of a wah wah wah up underscore X cube dot dot see.
Very simple or two important functions are the A.I. in it and a process.
And most of their work is encapsulated in these internal functions.
Right.
So we we sort of cleaned up what was generated by Cuba next to shorten the code and make it much more
understandable or digestible by Cuban mix generated include in the steps of Flight Number One Number
Two Number Three over here.
All of this generated by Cuba makes and it even tells us what is happening here.
No one specified a data structure to provide the reference of the activation slush working memory chunk
number to create an instance of the API.
Number three initialize the end end ready to be used in all of this was generated by cubit mix right.
We only included the print error here.
This also was generated by Cuban MCs and a lot more for simulating random stuff.
We just cleaned that and kept this.
So really we've not changed much.
Okay so this looks fine now.
I'm going to go back to the main function and add to some final touches to it as well.
So let's see what we have so far.
Okay.
It looks good so far.
We come over here we said if we press the brute the Blue Button user interface resets and then reset
the game as well.
And then after the whole delay one would come over here.
Okay that's a typo over here.
This one here the label should be index.
I like this one.
Okay.
And we have to put an else statement here over here.
I'm gonna see else if on a score second prediction
that probe is less than an underscore.
Output on a score data index.
I if that's the case then what we're going to do is so can prediction label because I.
And then second prediction probability
proud of I here and probe you cause an underscore output on that score data index.
I like this okay right.
So what are we going to do us.
Why is the prediction is done.
We are going to print out the predicted result on D on the liquid crystal display.
Okay.
Oh we've already done that over here.
We have this line for doing that.
We set a color to red font size 20 and then this the background color.
And then there's the position to print this.
And yeah we're print in first s.t. first drink.
We already place this inside us drink.
Okay we're not using the second string buffer.
So I'm going to comment this one out
okay.
Let's see.
And we sent in this to you as well.
Let's see if the US is enabled.
We may have or I may have disabled it some time ago.
Okay I'm going to enable a use it or you.
Over here.
This Amex underscore.
You set one on a score.
You got a score in it like this.
Okay.
It's looking good so we can certainly build now and see what we have.
We may have some arrows.
Um but let's see.
Click here to build
it's built in.
Okay.
It says We have five arrows.
K K
let's see over here.
It says float n n input data.
Data conflict conflicting declaration.
So the question is conflict and declaration with who.
Because if we come over here to the corresponding dots each file there is no conflict in declaration
at all.
It's the same thing here.
Yeah no problem.
Let's see the second one it says in data on declared.
Let's see.
Okay.
This is simple one.
So over here we simply need to pass.
I think I should make this clearer over here.
You know what a process a I run in data.
Data here should be the same arguments that would pass to the function so I'll copy this and then paste
the name that we gave it and an input data and I'll copy this as well paste this over here and then
I'll put data I see where the next error says okay.
This output data we've dealt with that one.
So let's view it again and see where we might end up with a conflict in a row.
Okay let's see
it says over here.
Incompatible implicit declaration of print f.
Yes of course because I have not included s d d i ordered H in this file over here.
Um but it is included in the main.
So what we can do is I'm gonna come over here to Maine and we have include sd d i not h over here.
I'm going to cut this and I'm going to put it in a y up hyphen cube.
X h each cause that this I'm gonna put it in this file here because this is called indeed dot c file
as well as the main file or you can simply have double include if you prefer but I've cut it off cut
sd d i ordered H from Main and I'm simply going to put it in this dot h file here up on the score X
cube underscore a dot h I'm going to include s DDA here because this is called by both the d up the
score X cube e I don't see and I mean that c file so once that is done I'm gonna click here to build
okay
include or provide declaration for print if
I see this rather strange
Yeah it it's rather strange.
Okay let's see something here.
Uh
okay let's see
okay so what is happening is that s a sieve this file is not reachable the up on the score X cube hyphen
H is not reachable.
Right.
So let's solve that.
Let's see it s path it s path is in the M S include forward.
I'll see I'll go and verify that it s exist in my in my path.
Let's take a look at the name again.
It's an embedded amnesty include.
Okay so I'm gonna come over here like we did earlier right click on project go to properties over here
like this and then I'm gonna come over here and then go to paths symbols and let's see if we have this
year we have schemes we have em list include over here we have this over here but it's not it's no find
in it.
So what I'm gonna do is I'm simply going to create a new file of I'm gonna create a copy of this and
called that is that there's a workaround I find for this but if one of you know why this is behaving
like this then certainly you can share it's in the forum but I tend to find problems with some of the
path and file location is using this open source um cube IDC show what I'm gonna do is I'm gonna come
over here I'm going to come to the C O selector Ford I'll just put a here or select my project right
click new and then I'm going to create a new file and then I'll simply call this an end not h mean in
neural network to teach and then finish.
So this an empty file and what I'm going to do for this an endless H is I'm going to take everything
in this up underscore X cube a dot H and paste it into my new empty file so I'll do control a two select
to control C to copy and I'll come to my n n not h control V to paste right.
So now this is going to be my head of file for up underscore up on this call cube e I don't see.
So don't let this confuse you.
So what I'm going to do is now when I come to my up on this score cube hyphen a dot see where I'm calling
up underscore execute hyphen a dot h I'm simply going to change it to my n n dot H so someone might
be confused if the F didn't see me do this in the video if you just help the project we don't understand
it you might find this confusing you could give it another name write it down and end what h you could
as well name it up on the score cube on the score e I to dot H or underscore dot H just to make it slightly
different from the original file so now this is going to be what is included here and I'm going to go
to my main dot c file as well and include the same and end it H this is main so over here we call it
up on the score excuse up on the score yeah.
What each.
I'm gonna include and then dot h.
Okay.
And now what I'm gonna do is I'm going to add the path of an end of H to my project's path and symbols
so this is.
So this my project folder amnesty is in my embedded amnesty and an amnesty.
I'm gonna open SDM 32 cube inside a folder and this is the new file we created and then dot H it's found
this is the path of it this thing and then s a dot h file as you can see your here.
So I'm gonna copy this it shows zero because we've not rebuilt our project so I've copied it location
right.
Gonna do control is to save whereas mine and H.
Gonna do contra s to save.
Okay so now I'm gonna come to my project properties and then over here under parts and symbols I'm going
to add new one here control V to paste okay apply and then apply it in close.
Okay.
Once that is done I'm gonna click over here to build
it's built in
it's still built in
it's built in
and it's built successfully.
We've got no error right.
So let's download onto our board and see how our neural network performs.
We're gonna click over here run then debug
it s download in
it's still a download in
says download in progress
okay.
Very fine
okay.
Let's see.
Download verified successfully.
I'm gonna click here to stop and then reset my board and see
so let's see.
This is my board.
I'm gonna run.
I'm gonna write a number in C or right to push the button to predict its predicted a 1.
Okay.
I was wrong.
I'll clean this.
I'll try another number.
Three price to predict predicted a one again.
Oh you raise a right for price to predict.
You predicted it once again.
Obviously a neural network isn't performing good at all right.
So what we're going to do is we're going to update our neural network.
So this gives us the opportunity to see how we can update the neural network.
We're going to take a bigger neural network compress it and then deploy that onto our microcontroller
and we're going to see that it takes just simple steps.
All we need to do is go to Kingdom X and then quantized those back into C code and then replace the
appropriate files.
So we're going to do that and hopefully with that neural network we would see the um the system work
as expected.
So we'll do it in the next lesson.