Hello.
Welcome back.
So let's build a truly a neuro network using the functions we created in our library.
In the last lesson I want to create a new I do script a Python script I should say was in New file or
price control s to save and I'm going to save this I'm saving this in the same folder in which we saved
our DNA and life library version one.
I'm going to call this to layer and then simple as that.
And I'm also going to copy the um the help script we wrote for a while logistic regression example followed
in the data cut or no cut.
I'm gonna come over here.
This project to cut or not.
We had this script called helper in the script.
We can take a look at it.
This load at the data for us our H5 file.
This script has just one function and this loads the H5 data for us.
So I'm gonna copy this I'm gonna copy this as well as that data set and images cause we're going to
be using them as well.
Copy to help her bring it all to Leah and then folder paste it over here.
Copy data sets and images
and I'll paste it over here.
Right.
So we've got our in library we've got our helper for loading our data and then we're going to implement
it in your network in this one.
Okay.
So we are going to use the same dataset that we used which is in the H5 four months later on we shall
see how to get actual images.
We're going to download actual images maybe about ten thousand of them and resize them and then pass
them through our neural network but now we can use the H5 format.
Okay.
So let's start off by importing the relevant packages that we need for this project.
So I'm going to import time
once that's done I'm going to import known by us N.P.
and after that I'm going to import H5 by
then and I'm going to import my to plot lib for plotting.
So I'll say import much plot lib dot pi plot SPL T and then I'm going to import CI PI for dealing with
images then O import P Pil Python image in library socio from pill
import Image.
Once that is done I'm going to import a were a y helper.
I'll see from helper to help us scripts we created from helper import load data set does the name of
your function
and I'm also going to import our library.
What's the name of the library.
It's called D and N underscored lib on this coffee one so I say from the in n that's lib on the score
D.
And in this clip on this coffee one import
and then put an asterisk meaning import all the functions.
I'm also.
Yeah.
I think I think we've imported all we need.
Okay okay.
So we can start off by loading our data
before before I do that.
I'm going to set my random number generator to seed.
I'm going to say NDP to random dot seed pass one over here and then I'm going to import my data.
Now like we did before we Queen to call a while load data load data function
let's see the name of the function.
Sure.
The
the function is called late load data set.
And this function is going to return to training set X training set y regional test set X or regional
to set while regional and a class.
Okay so we returnable 5 we return 5 items from this function does the function does the name of the
function and I'm gonna say equal to I'm going to store this in train X or Rick comma
Crane why coma test X or rig for original test.
Why and then classes like this.
Okay.
So after executing this we shall have our data set loaded into their respective variables right.
Now let's explore the data set let's make sure we know what we are dealing with when I come down here
and I'm gonna get the number of training examples by creating a variable called M Train in this course.
Train on the score X original dot shape index 0 right and then a number of pixels.
I'm gonna store that in a variable quote No more p x None P X and this we can get it by doing Crane
gonna score X on a score.
Rick does it shape this time.
Index 1 we can get a number of test examples by doing em test and then we do test score X on the score.
Original that S shape index 0.
Okay so from these three we can um we can print out certain attributes of our dataset.
So just come away here and put a print statement um
see a crayon in
IT training example
and I can just see SDR over here and then get my M Train variable from here.
Right next we can take a look a number of training examples.
So number of images string example images.
And I can print test examples to see print
test examples
see SDR.
And this would give it a name.
M test.
Right.
We can also print the size of each image.
So print
image size and we caught this from our number of pixels number of pixels over here.
So we can simply say plus string number of pixels
and then we do plus and then comma here.
And then plus screen again
no p x.
And then we know it's called three channels.
So I'm gonna put plus and then comb my hair again and then
I'll put three or four here
like this.
Okay.
What else can we print.
Um we can print the shapes.
Come over here print off or print
or see connects reach.
Shape the shape of the print example X
not a shape already.
We can simply do train X or shape to get this
green X or regional.
Copy this patient over here.
The shape.
And then I'm going to put one to put SDR around it.
Right.
And um if you are interested in getting the shape of the others test set you can do the same.
Um we can do for y help but we copy and paste and just so that we do all of them.
Um I'll do train Y
Y shape to get a shape
we simply fetch for from train y we've got train y over here.
Copy this paste over here right here and then I'm going to copy and paste and do it for the others
what it tests it.
So this becomes test becomes test this well test X original becomes test X your original test y
becomes test y like this.
Okay so let's run and see what we'll get from this.
Inspection control is safe click over here run a module.
Okay an error somewhere huh.
So there's an error in our DNA and lip one in our library.
Essentially our library script.
So I'm gonna open it.
Yeah it is.
The arrow is located here in our linear activation forward.
I think is because there's a typo in the word activation over here.
Right.
Line one hundred and eleven
okay.
It's on this line.
Linear activation over here.
Okay.
Control is to save on this run and see like I said the best test for our library is when we start calling
the various functions.
When I run this run module
what does it say.
No well activation is solved.
It says invalid syntax.
Let's see.
Okay.
This is the same file a Y DNA in the library version one far over here.
I have a typo when I did parameters P and I wanted to append l I'm using the square brackets or they
should be.
Is this just like the one we have up here right.
Like we did over here as well.
Contro s too safe.
Let's hope this solves the issue I've saved.
I'm going to run a while mortal again.
Come over here run module.
Voila.
So we have two hundred and nine create an example.
As you can see over here we have a 50 test examples.
The image size is 64 pixels by 64 pixels and we have three channels.
So because of the number of images the pixel size etc the shape of our train train set our train and
dataset is number of training examples which is two hundred and nine by the shape of the image or the
image size.
So we've got two hundred and nine by sixty four sixty four three and test train y.
We have two hundred and nine labels.
What s cut or no cut because the number of examples is two hundred and nine and test is just like we
saw in train.
We've got 50 we've got 50 test examples and in 50 labels for you know the Y.
So we shall continue in the next lesson.
Right.