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


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???