MythBusting: CNN vs Traditional Neural Nets

Enough boasting about CNNs, are they even worth the hype? Let's test out.

We will compare a normal neural network and a CNN against the MNIST dataset. We will compare them on the basis of accuracy. Let's check out.

Traditional Neural Net

First we will start with a normal neural network.

neural-net.png

train_nn.png

evaluate_nn.png

After training the neural network, we know that the loss is about 0.04 and the accuracy is 99.8% on the training data. But, on the test data, loss is 0.09 and the accuracy is a bit lower than 99.8%, this clearly indicates that the model was overfitting.

Convolutional Neural Net

But now let's look at the CNN here.

carbon.png

train_cnn.png

evaluate_cnn.png The CNN has a training loss of about 0.01 and the training accuracy is about 98.7%. But on the test data it has an accuracy of ~98.9%. And above all it took a lot less time training the CNN than a regular neural net on the MNIST dataset.

Conclusion

This comparison might seem subtle, but it goes a long way if you train it in production. As the data-complexity increases, the normal neural nets start to break. But the CNN remains intact.

This is why CNNs are preferred over normal neural nets in computer vision.

If you like my work, please consider following me on Twitter and LinkedIn too :)