top of page
Search

Which is the Winning Algorithm for images? CNN or MLP?

  • alnavar8
  • Jun 29, 2020
  • 3 min read

To compare if Convolution Neural Network approach is better than Vanilla Neural Network approach, I have performed analysis on the MNIST handwritten dataset to compare CNN and MLP. The training data consisted of 60,000 images and testing set consisted of 10,000 images of handwritten digits. The images were of the size 28*28 with 784 pixels in each image, performed for 20 epochs for both CNN and MLP.

Total trainable parameters in MLP were 932,362 with 7 layers and there were no non-trainable parameters. Where as in CNN there were 814,979 total parameters with 18 layers. And the non-trainable parameters are 192. Note that the trainable parameters are 814,778, which means that the no. of parameters to be trained are reduced in number in CNN. The loss and accuracy of both are displayed bleow. CNN achieved an accuracy of 99.26% and Loss of 2.41% while MLP achieved 98.33% accuracy and loss of 15%.



Conclusion with justification

Results:

  1. CNN achieved an accuracy of 99.26% and Loss of 2.41% while MLP achieves 98.33% accuracy and loss of 15%. We can observe that the loss is large in MLP.

  2. Comparison of the plot of Training Loss, Accuracy and Testing Loss, Accuracy. We can observe that in CNN there is no variance problem. But in MLP the validation loss increases noticeably.

  3. It is evident that MLP requires more layers compared to CNN and the total trainable parameters in MLP are 932,362 with 7 layers and there are no non-trainable parameters. Where as in CNN there are 814,979 total parameters with 18 layers. And the non-trainable parameters are 192. Note that the trainable parameters are 814,778, which means that the no. of parameters to be trained are reduced in number in CNN.

  4. The time taken to fit the model in CNN is 7 minutes and 42.19 seconds where as MLP takes less time i.e. 4 minutes and 04.67 seconds with 20 epochs each. CNN takes more time compared to MLP.


Conclusion:

  1. A CNN Architecture can perform better fitting to the image compared to an MLP for classification. This is because of the reduction in the number of parameters that are involved and the reusability of weights.

  2. MLP is considered insufficient in many applications as it creates a very large set of trainable parameters. This not only reduces the complexity but also makes the model overfit.

  3. Unlike CNN, in MLP we give flattened inputs which means that it disregards the spatial information. CNN is better for input with spatial information.

  4. In CNN the dimensions of the input image are reduced without losing important features and making it easy to process. This is very important feature when a large dataset is considered.

  5. The connection of neurons in CNN is sparse.

CNN is ideal for spatial information dataset such as images because it gives us a better accuracy with less parameters to optimize and very less loss but it consumes more time. MLP takes half the time required by CNN to complete the same task but the accuracy is generally that CNN and the loss is quite high.

Considering all the pros and cons of CNN and MLP we can say that applications involving simple dataset and requiring smaller time margin can effectively use MLP. CNN can be used when the application requires greater accuracy and is not time critical. Although both the networks can be improved in accuracy by precisely selecting the batch size, epochs, learning rate, dropout and the layers in the architecture.


Learnt Something new? Then hit the heart! How else would I know you like my content? And don't forget to subscribe to THE AI STUDIO for more AI related Content.

 
 
 

Comments


©2020 by The AI Studio. Proudly created with Wix.com

bottom of page