‫In this lecture, we are going to see the impact of pooling layer on the number of parameters we have
‫to train and the execution time on our CNN model.
‫First, we will run the CNN model that we discussed in our last lecture with the polling layer.
‫Then we will remove the polling layer from that model to see its impact on the execution time.
‫So this is the architecture of the model that we developed in the last lecture.
‫First we have the input layer, then cony layer, then pulling layer.
‫Then we have two dense layer and then output layer.
‫We are going to remove this pulling layer to notice its impact on the execution time
‫So the code will remain the same.
‫First we have the corn layer.
‫Then pulling layer.
‫Then platter layer.
‫Then Dense Layer.
‫We are calling this model as model underscore A
‫This is same as the model we develop in our last lecture.
‫And then we have a second model in which we are not taking this layer.
‫So first we have the corn layer, then flaten layer, then two dense layer and one output layer.
‫We are calling this model as model underscore B.
‫And later on we will compare the performance of Model A versus performance of Model B.
‫Let's just run this.
‫We can also look at the summary to get an idea of how many parameters our model our optimizing.
‫So here you can see for the first dense layer we have around one point six million parameters to train
‫if we compare it with Model B values.
‫You can see in our second model that we do not have any pulling layer, the number of cranial parameters
‫is around six point five million.
‫So overall you can say that there are four times more trainable parameter in your model without pulling
‫layer
‫And we know that the execution time is directly dependent on the number of parameters that we are going
‫to train.
‫So obviously we can expect that Model B will take a lot more time than model A
‫Let's just combine both of these models and then we will run model A four three epox
‫Then we will run Model B for three Epox
‫And after that, we'll compare the execution time for both models.
‫Let's just first run model A.
‫Now, we have trained our model
‫And as you can see, for each epox the execution time is around 31 seconds.
‫And after the completion of third epox, we are getting the validation accuracy of 82 percent.
‫And same as the accuracy for training data as well.
‫Now, let's run the model without the pulling layer.
‫Let's run this
‫So now we have trained our second model as well
‫And as you can see, the execution time for each epox is around sixty two to sixty three seconds,
‫whereas for our model one, the execution time for each epox was around 30 to 31 seconds.
‫So the execution time is almost double for our model B.
‫That is the model without the polling layer as compared to a model with polling layer.
‫You can also look at the accuracy score on training set, the accuracy of our model B is more and on
‫the validation set.
‫The accuracy is almost the same for both the models.
‫This is because when we are polling for pixels and the one pixel, there is some information loss and
‫that information loss is resulting in the lower accuracy.
‫So if you are using polling layer, your execution time will be less and the accuracy will also be a
‫little less as compared to a model without polling their.
‫In this case, we have only used one convolutional layer, but in real life scenario, you may have
‫to use multiple convolutional layer.
‫And in such cases, a use of polling layer becomes much more important.
‫So using polling layer, you can significantly reduce your execution time without impacting much accuracy.