# Neural Networks: Chapter 4 - ConvNets

In our ** previous post** we explored

**and got a high level understanding of**

*What are Layers?***But then again who is looking at just a superficial knowledge.**

*What are the different types of Layers?*So in today's article we will dive deeper into our first and most widely seen category of layer - *Convolution Layer.*

### What is Convolution?

Convolution is the process ofcombiningorprocessingTWOinputsadversariallyto extract orformulateaUnique Output.

Or simply put, It is the mathematical operation responsible for transforming and extracting features from the Input.

Now let's talk in terms of Neural Networks. The reason ** Convolutional Layers** are so widely used in AI, is because of their

**.**

*phenomenal capacity to extract features from Input Matrices fed to the network*Based on the type of Kernel Matrix you choose, the type of extracted Features also vary. At the end of the day it is just mere ** Matrix Multiplication** to transform the Input.

Now we all are aware about the fact that most of the AI problems dealing with ** Cognitive Senses** and Interactions with the Environment deal with data types such as -

**etc.**

*Images, Sound, Video*Now a thing to note about all these data types is that all of them are mere differentrepresentation of Matrices, perceived in different manner.

Now if we were to process these Matrices using Convolution, it would be astonishing to you all to look at the variations in the results of the transformed data, based on the type of ** KERNEL MATRIX** that we choose.

I know, I have given an overload of information, but need not worry. As we progress, we will be dealing with all of the terminologies one by one.

Before we dive into Convolutional Layers, below is anshowcasing the capability and working ofillustration.Convolutional Neural Networks

### What are Convolutional Layers?

** Convolution Layers** are the group of

**present in the**

*Neurons***which are responsible for performing the task of Convolution to extract relevant information and to transform the Input Matrix into the desired format of the subsequent layer.**

*architecture*Now before we explore How do they work? Let's try and understand what do they need before they can get to work. Some of the ** terminologies** which are very essential to understand before going forward are -

*Kernel Matrix**Stride**Padding*

** Kernel Matrix **- It is the

**which is used over the Input data, by**

*secondary Matrix***it**

*imposing***over the whole stretch of the feed, to transform and extrapolate information. Ideally the Kernel Matrix has**

*iteratively***than the Input Data (usually Images).**

*dimensions smaller*** Stride** - As we mentioned above that the Kernel Matrix is used to perform recurrent Mathematical Operation over the whole stretch of the Input feed, now Stride is the parameter which

**to impose over a**

*decides the shift in the Kernel***.**

*New Segment of the Input*** Padding** - As Convolution generally downsamples the Input size, basically reducing the size and dimensions of the feed, it is necessary to Pad the Input with certain

**in order to**

*pre-defined values***the**

*retain***of the Input.**

*Original Dimensionality*Now that we have understood superficially the definition of various parameters involved with Convolutional Layers. Let's go ahead and see How do they work?

### How do they work?

Now that we had a glimpse into what goes into building a Convolutional Layer, let's take a look at how do the function, to help us understand the concepts better.

First let's understand what do we mean by the fact that there is a Kernel Matrix that goes iteratively over an Image to generate a new Matrix.

As you can clearly see - ** GREEN** - Image

**- Kernel Matrix**

*YELLOW***- Extracted Feature**

*PINK*The above illustration defines the process of how a Kernel Matrix performs Matrix Multiplication over the Input to extract and transform the features. But now the next obvious question is *What makes it move?*

That is what we call ** Strides**. Let's take a look at an Illustration to understand how would a Kernel Matrix perform with a

**.**

*Stride = 1*Till now we have seen how would Convolution perform on a Single Channel Matrix. But let me ask you a question?

Are Images Single Channel?

The answer isNo

Images usually comprise of3 Channels-andRed, GreenBlueor also known asRGB

That bring us to our next question -

### How to Implement Convolution on Real Images?

Ideally speaking, the overall concept of Matrices and Kernels remain the same throughout the implementations, what does change is the output.

So based on one's requirement in the architecture, Convolution can be performed to either ** Merge** all the features or

*more importantly create separate Channels for each extracted Feature.*Let's take a look at the below illustration to understand better about the prior case.

As you could clearly see, the process of convolution results in an ** Aggregation** of all the extracted features and those are being carried forward into the subsequent layers.

Thanks to the years of research we don't have to perform these computational exhaustive operations and honestly pretty redundant and boring, we have Open Sourced Frameworks such as ** Tensorflow** and

**that help us in this exercise and speed up the processes significantly.**

*PyTorch*### Conclusion

If you have followed through this article, then by now you would have a good understanding of the** Inner workings of Convolutional Layers** in Neural Networks.

Note- These understanding of Layers prove extremely crucial while implementingcustom architecturesforcomplex problems

As most of the Novel solutions coming from you all readers is custom built for particular use cases. In such circumstances pre-trained designs may not be the best solution and that's when such understanding becomes vital.

I hope this article finds you well. ** STAY TUNED** for more. 😁