Now, this is the architecture we are going to use for our CNN model.
If you remember last time when we ran in and model on this problem, we used this side of the network.
We first use flatten and layer, then dense, layered with 300 neuron, then dense layer with 100 neurons
and then the output layer.
We are going to add CNN layers before this.
So this is our input, 28 by 28 pixel cross one.
So 28 pixels as well, 28 pixels as height and one as the channel.
We are going to use a filter size of three by three with the straight off one.
And then this will be our convolutional layer.
Since we are using filter size of three where three.
And we are also using a padding as valid.
We are ignoring one pixel from each side.
Since our padding is swelling.
So the convolutional layer, we are going to get this 26 by 26 and to 32, we are going to use 32 different
filters for this convolutional layer.
After this, we are going to use to where to Max, bullying.
So finally, after this corn layer, we are going to get 13 by 13 and to 32 cells in our pooling layer.
Now, we have to add some dense layer as well.
So we have to convert this 3D object into one dimensionality.
So we are using flatten layer.
Then we are going to use to dense layer.
First one with 300 neuron.
And next one with hundred neurons.
And then we are going to use an output layer with 10 neurons.
Since we have to identify ten different classes, the code is almost similar.
First, we have to create a model object.
Then we are going to add the convolutional layer.
We'll write model, dot, add and then get us dot layers, dot com, 2d.
And as parameters, we want to do filters.
We want to have over feature of size three by three.
So we have to grow.
Kernel size has three comma three.
If you want double the size of four, wherefore you can write for pomoc forward.
By default those start value is one.
We are going to use the same.
And we are going to use buiding as valid.
The activation is always relu.
And the input shape is 28.
Cross 28.
Cross one.
If you are dealing with any Collodi images, you have to give values for channel as well.
So for Galardi images, this should be three.
This should be the height, weight and then the number of channels.
So this is a work on layer four or pulling layer.
We can edit using this syntax model a lot and then Gaydos dot layers dot max pulling 2D.
And then here you have to give the dimensions of your window.
We are going to use deceptive.
We love to cross too.
That's why we are giving to comment to as a parameter.
After this, we want to convert our three dimensional matrix into one dimensional matrix.
So we have to use flatten and after flatten.
We can use our dense layers as we did in and then.
So we are adding another layer with 300 neurons.
And then another layer with 200 neurons.
And for both of these layers, we want our activation function to be of RELU.
And the next layer is our output layer.
We want to classify 10 different categories.
That's why we are using 10 neurons.
And that tuition is softmax activation because this is a classification problem.
Now, let's run this.
No, similar to last time.
We can use Dort somebody Martek to get details.
All four were Mortel architecture.
Here you can get information of all the layers or does the shape of those layers and the number of parameters
that you are going to train.
Using this model architecture,
no important thing here you can notice is that the number of parameters we are going to train is in
millions.
So in this dense layer, we have around one point six million parameters to train.
Now, if we have not used Max fulling layer two, this would have been around four million or five million
neurons.
So so using max pooling has significantly reduced the number of parameters that we are going to train
in the next lecture.
We will try to train a model without a pooling layer.
And there we can clearly see the difference in number of parameter and the execution time in the models
with the pulling layer and without the bullying layer.
The next step is to compile the model now, since we have exclusive might be label classification problem.
We are going to use a sparse, categorical and Cross and Groppi and we want to use Optimizer as a study.
So class state, Verdean descent.
And we want to calculate the accuracy.
Since we are doing the classification problem, it's compiled this model.