Now, in this lecture, you're going to be on Mardle using Cadeaux.
But before that, we will do one small thing.
We will decode another small set of our training examples as validation set validation said is used
to tune the model, hypothetically does.
So we'll just take our first 5000 examples as validation set.
And the remaining we will see them in another variable called partial training, say.
So here I am setting the NICE's or phosphide told him in a variable called Val NICE's.
Now, I use this very well could pick out the information of First Beethoven and stored it into revalidation
images.
So the first thousand green images are now stored in val images.
The remaining part of the training images is stored in part underscored grainy images.
We do the same thing with labels.
The first 5000 labels are stored in that labels and the rest of the labels are stored in part grain
labels.
So we have created two parts of the trading examples.
One is validation set and one is the partial dating site.
Will use the partial training set to train the model and the validation set will be used to do only
hyper barometer's.
And you will see the use of validation set in the coming lichter's.
Now, there are two ways in which we can define that model using get us.
One is using sequential EPA and the other is using functionally EPA.
Sequencing the EPA is used when you want to make a normal neural network with linear stack of layers.
The functional Libya is used for a big, complex network structure where you have multiple usages of
several small one.
It looks wiltsie an example of functional EPA.
When we build regression model for this classification example, we will use sequential EPA.
Now we'll be taking three steps in defining a model.
The first step is defining the network structure.
This includes setting up the number of players, number of neurons in each layer and the activation
function to be used in each layer.
This is captured and this part of the code.
The second part is configuring the learning process.
This includes selecting the lost function and optimize it and some metrics will be monitored.
This is this part of the good.
The third is specifying the operations and training the model.
This is done in this last part of this called.
So let's start discussing each line of good.
One by one here.
We start by creating a new variable called model.
And this video will contain the information of the structure of our network.
This is the function we use for using sequence, the EPA us model underscores the question then to start
defining the structure.
We use this pipe symbol.
This pipe operator comes with the magnet package, which is auto installed.
When we install Kiraz package, this is used for passing values as arguments to a function.
We can do away with the symbol also.
But the use of this symbol makes the code more readable and compact.
So as a good practice, we will use this operator.
This is a pipe operator.
And if you remember even this operator that we used by assigning Dukane images and train labels, this
multiple assignment operator.
This is committers Xerox packet, which was also part of the key aspects.
We're using this also because it makes the court compact.
So first, we plan on the input layer, my flattening.
I mean that we have 28 micro indeed image.
We can turn it into one dimension by putting all these pixels in one line.
What does happen if you have this three by three two dimensional array?
You can flatten it by putting these multiple rows in front of each other.
So this will become a one dimensional Eddie.
This step is important as we have to give a straight say of input values in place of what to lean,
but you can converted in one dimensional using edit easier function also.
But when we have cameras, why should we bother?
Just specify here live flatten like this and specify the input shape.
That is what is the kind of input that this layer is having.
It will automatically convert this 28 by 28 input into seven eight report pixel values for the next
year.
Next, we specify the details of what thens had to live.
That is, we are telling that this list is Dennes, meaning each neuron is connected to all neurons
of the next year.
And in this layer, we want one twenty eight neurons and the activation function for all these neurons
will meet the loop that is rectified.
Linear Unit two.
In this way we have defined one hidden layer.
It's a densely.
It has 128 neurons.
And they look at vision function.
Next, we specify the output layer.
You can add more layers also.
But here I'm using only one hit.
And one output layer in this last net.
We have 10 neutrons waiting because we have been classes to.
We predicted each of these neurons will be predicting the probability of one class, such as whether
it is a shirt or a boot.
And if you remember from your theory lecture.
This Softmax activation, just make sure that the sum of all the probabilities come out to one.
So this last letter has 10 neurons with softmax activation.
That's all for the structure.
In short, it is a 70, 80 foot hyphen, 128, 110 neural network.
Once we have run the entire code, I would suggest that you come back to this point, an experiment
a little bit here, right.
To see what is the effect of having more lives.
And what is the effect of increasing or decreasing the number of neurons.
Indeed, in these next underscored,
you can see that a new variable called model is created and it has the structure stolen in it.
Now, let's look at the second step at this step.
We configured the learning process.
In this, the first thing is specifying optimizer.
We have discussed the concept behind stochastic gradient descent.
This is Didi's is that only there are other optimizers also with small differences.
Other optimizers include Adam Automats Prop and few others.
In fact, in the coming name, we may see a few more added to this list.
But to answer the question which should be used when ideally the optimizer depends on the shape of the
error function go.
But we do not know that shape.
So we do not know the ideal optimize it.
But practically in most of these scenarios, all of these work very well.
It's just that for some scenarios, as Didi's converges faster and for some situations, automats prop
converges faster.
So my suggestion would be labeled Branly model ones with Edgerly.
If you think it is taking too long to convert and your alternative much improvement and training, it
is always worth a short brio automats prop optimize it also.
Let's move on to this again parameter which is lost function.
We have discussed this in the theory part for classification models, views cross entropy and for regression
models we usually mean square values.
But within Crosson probably you will find three options.
Which of these three should you use different on the type of problem you have?
These arbitrary names, sparse, categorical cross entropy, binary cross entropy and Categorical Cross
and Brookie.
If your problem has two glasses to be predicted, like whether a male is spam of Norks, man, use deep
binary cross Brookie.
If you have multiple classes such as this problem where we have fashion objects and each example is
exclusive, meaning each image contains only one object to be predicted.
Then we use sparse, categorical cross and Ruby.
So that is why I have written losses equal to pass categorical course and repeated.
If we have multiple classes and one observation can belong to many classes, for example, if we are
labelling, whether an email is from someone you know or not, and we are also labeling whether the
email is important or not.
Here, one e-mail can be bought, it can be from someone you know, and it can be important.
So it may belong to two classes at the same time.
In this interview, we use categorical cross and Droopy.
I hope you understood this.
Here's a test of what I just said.
You can look at this.
Come and take part here.
To understand the three Crosson rupees.
The third parameter is metrics.
This is not mandatory, but we specified this to monitor the performance of model on the training.
Basically, we would like to see the improvement and accuracy of our classification model on the mean
squared error of our regression model over each epoch.
As I told you, we go over the entire Bringuier does it several times each time.
We will calculate the accuracy of our model.
At that instant and store it so that we can see if the learning process is having any improvement in
accuracy or not.
So that these three.
But I would just say we can run this part of the code.
Now we are configured the learning process also.
This brings us to the third part where we actually train, not more than training is done using the
correct function within feet function.
We have to specify the input variable first.
That is the posture training dataset that we will input.
Then comes the actual output corresponding to those inputs to the actual output is stored in partial
train labels.
So that is the second parameter.
Next, we specify the Époque number.
This is the number of times an entire training data will be put into the model.
We said this 230 for this example.
Then we have that site.
This is the number of observations which will be used during each.
Forward and backward propagation.
Step two, we take a bad size of 100.
Lastly, we tell that we have a separate ventilation data also, which is a list of valid images and
that labels and we would like to see the accuracy scored on this validating data as well.
Keep in mind that only this part, brain images and bartering labels will be used to bring any more
than this validation data is like this data.
In this scenario, that is our model will not have seen the validation data when it calculates the accuracy
on this validation data.
Well, let's follow this line of thought as well.
And this will be number one.
Well, you can see that neural network model is getting green.
And the accuracy and loss value is being recorded for each epoch.
In the next video, we will see the performance of this train.
More than.