Convolutional Neural Network (CNN)

Implementing a CNN is not exactly a straight forward matter. The general approach of the content on this page is to provide the overall code to implement it, and then to break down the code piece by piece with explanation.

CNN in Python 3

PyTorch

The first thing is to load the data…

The second step is to split the data into training, validation and test sets:

Although we have split the dataset, depending on use we may not have loaded the data yet. For example, if we are using images then the above code merely splits the dataframe that lists the location of those images.

Now we need to create code to load the data:

The reason we use the dataloader is that it may require too much ram to put the model into the data correctly so we are using batches of data to lower memory requirements.

The code to load the data is complete, so we need to create the model:

The above code creates the model architecture. Here is a visualization of the architecture we created:

What this achieves is that it???

Discussion

Reference

https://arxiv.org/pdf/1512.00567v3.pdf

https://towardsdatascience.com/pytorch-basics-how-to-train-your-neural-net-intro-to-cnn-26a14c2ea29

https://www.analyticsvidhya.com/blog/2019/10/building-image-classification-models-cnn-pytorch/

https://pytorch.org/tutorials/beginner/blitz/cifar10_tutorial.html

https://medium.com/@hasithsura/audio-classification-d37a82d6715