# Convolutional Neural Networks

Understanding of a Convolutional Neural Networks(CNN's |ConvNets)

Convolutional Neural Networks are used mainly for image processing, classification, recognition, segmentation, and other autocorrelated data because of their high accuracy.

## What is Convolution?

It is a mathematical combination of two functions to produce a third function.

# Layers used to build CNN's

- Convolutional Layer
- Pooling Layer
- Fully Connected Layer

# 1. Convolutional Layer

It extracts features from the input image and preserves the relationship between pixels by learning image features using small squares of input data. As shown, it's a convolution of the input image matrix multiplies with the filters (called* "***Feature Map"**).

There are different types of filters used in CNN's for other purposes.

## Strides

Stride is the number of pixels shifts over the input matrix. When the stride is 1, we move the filters to 1 pixel at a time. When the stride is 2, we carry the filters to 2 pixels at a time. For example, shown below is the image with a stride of 2.

## Padding

The number of pixels added to an image when processed by the kernel of a CNN. For example, the image with a stride of 2 and 1 padding layer is shown below. If we don't want any padding, then make it as padding is equal to the *same.*

# 2. Pooling Layer

The process of subsampling or downsampling filters through dimensionality reduction but retains essential information and is also used to control overfitting.

## Types of pooling:

- Max Pooling
- Average Pooling
- Sum Pooling

## Max Pooling

The pooling operation extracts the maximum value from the image portion covered by the kernel.

## Average Pooling

The pooling operation extracts the average value from the portion of the image covered by the kernel.

## Sum Pooling

The pooling operation extracts the sum of all values from the portion of the image covered by the kernel.

# 3. Fully Connected Layer

We flattened our matrix into a vector and fed it into a fully connected layer like a neural network. Simply, it connects every neuron in one layer to every neuron in another layer.

Finally, connecting are these layers together to create a model, and we have activation functions such as ReLU, Softmax or Sigmoid to classify the outputs.

# ConvNet Architectures

These are used for image classification, object detection, image segmentation, and many other more advanced tasks. Some of them are shown below:

- LeNet
- AlexNet
- GoogLeNet
- VGGNet
- ResNet
- ZFNet