Hello.
Welcome back.
So in the last lesson we realize our neural network wasn't predicting accurately what we're going to
do in this lesson is take a new model a new carriage model and its topology and convert them into C
and then update our system updates or embedded firmware with this model.
So this is my project folder.
Before we do that I would just show you the model we going to use.
So this is our model model dot H5.
That's the size nine hundred and thirty five kilobytes.
The new model we're going to use is about four point seventy megabyte.
That's the new model we are going to use.
And this um this is it's Jason.
It's a topology.
Right.
So what are we going to do here is create a copy of our current project just to get access to our Q
But airMAX.
So what I'm gonna do is I'm simply going to come over here.
This is my project folder within this I have my amnesty and I can come here and open our project.
This project here it's located in this folder.
I have my parents FORWARD OUT THE PARENT photo I I'm calling it embedded amnesty.
Right.
So I'm gonna create a copy of this and I'll simply use this as this crutch folder.
Well I need to do this with this is to generate the um the what you call it the the weight and the neural
network in the C code.
I'm going to rename this to scratch.
And in fact we could have just copied a word
we could have just copied simply the the Cuban mix project and then continue it from there but it wouldn't
cost me anything to create a complete copy of the full project that is why I copy the full project.
So now I have to.
This is the actual working one this this crutch one we simply going to load in a new model here and
then replace the files.
So this my embedded m this crutch.
And then within this I have my M next.
And I'm going to go to middle where everything is the same.
We've got our eye stuff.
Yeah right.
So I'll come over here in my source in the source folder we've got network.
And then we've got network data.
These are C files I'm going to add the word old I'm going to append old here so that this will indicate
this is our old network.
So I'm gonna have network on this quote old network data underscore Oh.
Because when we generate there's going to be a new network in network data.
Right.
So a network data on the scoreboard as well.
When I go to include folder and do the same thing a Health Network and then network data we're gonna
rename this network and let's call owed and then network data
on the scoreboard as well.
Okay.
So um when I come here and open Cuba makes I'll just close this project.
Oh uh Cuba I.D. project.
I'll save everything.
Right.
Cuba makes us open it
and network connection is required.
Okay.
My internet is off.
That's why I'm receiving this I'm going to turn it on.
Do you want to set your connection parameters.
Oh I would just say no.
Okay.
So this Cuban makes
in fact rather than creates a copy of our project.
We could have just started you know a new project in Cuba makes and then select at the same board just
to initialize our new network.
But I know you understand that.
So what I'm gonna do is I'm going to click this site here.
I still don't have internet connection.
Sorry bother.
So like I was saying we could have just opened.
No.
Uh we could have just opened Cuban mix and then go to new project and select exactly the same board
and created it.
That's one where we could have done this.
The method we're currently using is just creating a copy of our current project and double clicking
on the Cuban mix.
I can but I hope you understand that it's really the same thing.
Or maybe at the end of this process you would see what we are trying to achieve is a tiny thing.
You could have done in different ways.
In a way I'm going to click on this tab over here to take us back to where we selected our board.
It says is connected to the server to download something.
Okay let's wait.
Okay.
So this is our board selection page.
We're going to select exactly the same board.
Where is it.
It's over here
and the microcontroller is the SDM 30 to f 4 2 9.
I am going to come to MCU underscore MP use selector.
It is the M 32 f 4 2 9.
I Okay so I just select any of them to 9.
I what I'm gonna do is I'm gonna enable artificial intelligence down here and then over here I'll select
carers because the model listen carers and type I'll see module and topology and then approach to the
location module location or click browse over here and then I'll go to the location of my model it's
over here M.A. carers model.
It's a new to this my model and then our prowess for the topology as well.
It's in the same folder.
It's a dot Jason File.
Once that is done I'm going to analyse to see if it fits on the microcontroller that we've selected
so I'll click on the line over here and it's going to run the analysis.
It's on the light in
so over here it's analysed.
It says the minimum flash requirement is four point eight to make a byte and a minimum requirement of
RAM is one hundred and two point one for kilobytes.
And the interesting bit is over here you can see that we've got no list here at all.
It says MCU slash MP use list zero item meaning the original s team 32 bought currently within 10 or.
They'll be able to accept this module.
So what we have to do is compress it.
If you're using a different version of Q that makes you might in fact receive a dialog box telling you
the model is too large for the board selected because this the board we selected.
So what I'm gonna do is I'm gonna compress this outcome to compression and I'll select for over here
and then I'll analyse again and let's see what happens
this generates in the network
okay.
Still there's not much we have zero over here.
Okay.
I'm going to compress by 8 and C I'm gonna come over here compress compression eight
let's see what we get
okay.
So after compression of eight we have two boards listed
we've quote the estimate that it to four to one estimate that it to f 4 2 9 HP T X mean and something
else and then we've got this one too.
So we know it would fit in our board.
Our board is 4 to 9.
Uh does it say what s g or not.
But it would certainly fit here if we read if we read over here.
It should tell us the amount of flush and the amount of ram that the board has.
Let's see.
Okay.
Right.
It would fit in this board.
It doesn't say the flush and the RAM amount but I've read a data sheet before we can check the data
sheet from here.
If we want so in a way now we know this would fit with a compression factor of eight.
So we can go ahead and um and use our port but we have to compress it by 8.
Right.
So I'm going to
I'm going to close this project.
Uh the board selector.
And come back to the projects and under additional software.
This is our project remember we opened an already existing project so I'm gonna come to SD microelectronics
over here under additional software and click this
and then over here we're going to load a new model.
When I close this and then I'm going to browse to the location of this new model.
When I click here to browse and then oh located it's over here.
Cuba Max Kerry's motto new and that's the motto.
And then the topology
is the same place.
This over here
and we can analyze once more and see.
Okay so over here it would tell us joined us on a lot uh analysis process.
We'll get to know what a fits or not properly.
Okay.
Like you says so far here.
Required rum or flush size for the network is bigger than the available rum or flush.
So this is why it's important to analyze.
We first did a quick check.
That is if the truck that we initially in initially did is to check before you buy the boat by if you
already have the boat you can run analysis in here.
So it's analyzed in your network and obviously larger than the amount of space we have.
So one thing we can do is run a compression I'm going to start with compression of four over here and
analyze again
it's analyzing
okay.
It says rendering the model
right
let's see.
Over here over here when we selected compression of four it was able to pass analysis and yet on when
we did a quick check compression all four didn't list any boards.
But over here when we checked for the four we were able to pass the analysis.
So this is the final decider on what had whatever fits or not.
Once you've uploaded a model into the project and run the analysis after you've selected everything
they brought aboard right.
Course on their own if you remember when we used that compression of four.
We didn't have any boards listed in the area where boards are supposed to be listed.
However over here we find that's just compression by a factor of four.
It fits into our current board.
So it is important to run this final analysis over here.
Right.
So it fits in the board.
We can validate on the desktop or click over here validate and it's validating
okay.
Right.
And it gives the the values for the arrows over here.
So you can um you can go through them.
If this type of thing matters to you right.
Okay.
One other thing we can use this for you show that graph the network graph.
You can actually click show graph over here and give the graph of the entire network.
Right.
So this on your network you can look at it or you can spend more time on it.
Right.
So all we have to do after doing this is simply generate our code again and copy their respective network
files to our own projects and rebuild that old project.
So go back to the um the project manager over here.
Keep everything the same.
And I'll simply click generate code over here it's generating
okay.
It's taken a while.
Right.
Generation is complete.
I'm simply going to go to open folder and I'm going to close.
Cuba makes no.
We're done with that.
Okay.
So does the photo.
This is our M.A. on this course crutch embedded or open source over here.
Now we have a own network data.
This the new one this the old one remember the old one.
We added the word owed to it.
So we have these two new files old network data and the network data itself.
Right.
So what we're going to do is I'm going to just show you the network as it's a piece indeed.
I mean the project before we start doing the changes so I'm going to go to a war work and project.
This is the project you're working with.
We just created the scratch one so I'll come back to my project over here and then you open it.
I come over here and then double click to open my cube IDC
and then click launch
it's open.
Right.
So that's where we left off
I'm gonna open this.
Oh it's still rendering from down here.
That's way too bit
this weight.
OK.
One hundred percent so I'm gonna close everything here actually just to focus what we have.
Close ball I'll say I'm gonna come over here to my project to my application use and then this is the
network dot see.
This file was generated from our module.
This is still the old one.
We've not changed with a new one yet.
I just want you to see what it looks like.
We've not analyzed this yet so this is what was generated when we provided our python script.
Cuba makes generated this for us.
This entire file.
This is one of four files generated based on a watch network model in our network topology right.
It's actually added to date and the version of Cuba mix used and it's added all the characteristics
of a model here.
When we go to our network data Nessie we find a wait.
So this the wait as you said these are the wait right.
It ends at line number ninety four thousand and sixty six.
Okay so this the old file and difficulty our respective interface files meaning the respective dots
each files we have to network underscored data I don't see which is the implementation file and we have
to network underscore data that's H which is the interface file the interface file as you may know allows
us to be able to call these C functions from other files.
Right.
So we have the dots each false as well.
We can take a look at those as well we come to include and then we locate it over here.
This is network on the score data on age.
This what it looks like very short and then we have the network dot h over here and that's what that
looks like us well just a number of functions.
We have the AA in it a create a I get arrow etc. so I'm going to close cube a I now and go and do the
replacement exit okay.
So this is still the current project that we are working with.
I'm going to rename the network files in my current project to vote right.
I'm going to have network underscore old network and that's called data underscore mode just like we
did in our scratch project so that in case we want to take a look at the old model we can take a look
at it again.
So I'm gonna come over here.
This amnesty is my follow go to source.
This is my network file.
Rename this or simply at underscore owed at the end and then there's the data version that's work on
the score data.
Append underscore owed at the end as well.
And now I'll go to the dots H files or come to the include over here we have network and this call out
on a score note here.
Network data does these dots each forward I should know at underscore mode here as well right.
So now I'm going to copy my old my new generate my newly generated network.
So this this crutch forward at this where we generated one new model.
So I'm going to this.
Okay I'm going to open side by side.
This is my current project folder amnesty.
This is this crutch.
They wonder we use for a quick generation the new generation.
This my current project I'm gonna come over here and copy the new model here.
We have network and then network data.
I'm going to copy them into my current work in forward.
Copy paste right and then I'm going to go to the i n c to include for food as well for both of them
and then copy network and network data.
Yep.
Dead dot H files network
and then network data.
Copy this and then I'll paste it in my work in project folder
pasted over here.
Right.
So now I'm going to open my project again this time I'm going to be using the new network that we generated.
Come over here.
Double click to open over here.
Launch
it's open right.
It's finished opening
it's slowed and down here.
We've got to wait a bit
it's still loading okay.
One hundred percent okay.
So let's take a look at our new folks.
We just checking the network to see the network on this court data.
Don't see fault cause we verify the old ones ended around foul are the old network on this court date.
I don't see file ended around line number ninety six thousand.
Let's take a look at this new one.
I'm going to come to application you sir and then network underscored data.
Don't see double click.
I'll just say no.
Over here.
And then I'm going to scroll down to see where it ends.
So this one ends around one hundred and twenty six thousand.
Obviously there's a bigger network compared to the first one.
Okay.
So we're going to reboot our project and then download onto our port.
Going to click over here to build it s brought in.
Okay.
We've got no error.
I'm going to download onto the boat click Run debug over here okay.
It's downloaded successfully.
I'm simply going to click stop over here and then I'm gonna reset my board and then test out a neural
network.
So I've reset my board.
This is my boat.
I'm going to write the number two and then I'm going to press to predict it's predicted to.
Excellent.
I'm going to race.
I'm gonna write three press to predict to predict predicted three.
That is excellent.
Your race.
I'm gonna write about nine press to predict.
It s predicted nine hobos.
Zero press to predict.
It's predicted 0 0 0 7 press to predict.
It s predicted seven hobo.
I try to write mine this way.
Let's see.
Press to predict it's predicted to k.
It was a tough one.
So this is it.
Basically um you can play around with it s more in fact.
In fact we can also monitor our performance or our A.I. experiment.
We can monitor you through our center monitor cause we've initialized you out of here.
So let's observe it.
I'm gonna open terror term over here and then I've got zero plot.
Um of course zero also to my SD microelectronics virtual comp and then okay over here and I'm going
to increase the font size a bit.
Let's see
over here setup font
I'm gonna select font size of 16 over here okay.
And then I'm going to press resets on my board.
The board has reset and I'm going to write three on my board.
Okay I've got a change that comports when a change comports entourage to the board right here.
I mean I've got a change to Boatwright sorry.
This the right port right.
Okay I'm gonna press reset to my board and I'm gonna come over here to play a buffer.
See that buffer when a press reset to my board again.
When I write three.
Okay so it's giving me the x and y movement of my of my finger or the stylus I'm using on the screen
and then I'm gonna press predict.
Okay.
And it's predicted forty eight and that's the probability probability of zero zero.
And then there's a probability of zero sure he has one no problem.
I'm going to clean and try again when I write a three price predictor again.
It's predicted three would have probability of a hundred percent and then its second guess is five would
have probability of zero.
Remember we have the first prediction and second prediction is the second prediction value.
I'm going to press clean again and then write to six press.
Predict okay this time it's predicted the first guest predicted a five.
With this probabilities are points over zero point nine.
The second gets predicted an eight which is probability no problem.
So clean and then write to press to predict you predict at a 2.
Wow.
What's your point.
5 and a 7 was reported for.
I'm gonna clean again and then let's see.
I'm gonna write zero 0 0 that and then press to predict predicted a zero with zero point nine nine confidence
and then a three which will point to zero three.
So you can monitor the results on these rural plots as well.
This all the rest.
If you have any questions at all just let me know and thank you for watching.