DEV Community

Aravind B N
Aravind B N

Posted on • Edited on

CNN (Convolution Neural Network)

Hello, I'm Aravind, working as a junior software engineer in Luxoft. In this article, I've made an effort to provide a clear overview of the Convolution Neural Network(CNN). This is one of my interests in Machine Learning(ML). so here is the basic article on the Neural Network.

Introduction

Convolution neural networks are a type of deep neural network that is used to study visual perception. They're a member of the AI and machine learning (ML) family. Deep learning rose to prominence in computer vision as neural networks outperformed rival methods on a number of high-profile image analysis benchmarks.
Convolution neural networks (CNNs) are a strong tool for learning meaningful pictures and other structured data representations. These properties had to be manually designed or produced by less powerful machine learning models before CNNs could be used effectively.

What is CNN (Convolution Neural Networks)

A CNN is a type of artificial neural network that is designed to preserve spatial correlations in data by using only a few connections between the layers. Because the input data is arranged in a grid format, CNN’s are able to create extremely efficient representations of the data input that are ideally suited for image-oriented tasks and then fed through layers that preserve these relationships, with each layer operation operating on a small region of the previous Multiple layers of convolutions and activations make up a CNN, which are commonly alternated with pooling layers. Furthermore, CNN’s feature fully linked layers at the end that compute the final outputs.

Image description

Need for CNN
In the past, image classification models classified images based on their raw pixels. Cats can be classified using a color histogram and edge detection, which allows you to categorize them based on their color and ear shape. This technique has proven to be effective, but only until it encounters more complex versions.
The CNN model is a form of neural network that allows us to extract higher representations for image input. Unlike traditional image recognition, which requires you to define the image characteristics explicitly, CNN takes the image's raw pixel data, trains the model, The characteristics are then automatically extracted for enhanced classification. Because it does not analyze all available variables, a classical image classification system.

Layer of Convolution
The window is swept through images using a convolution, which then calculates the input and filter dot product pixel values. As a result, convolution might emphasize the most important features. These convolved features will always vary based on the filter values generated by gradient descent to decrease prediction loss. Additionally, the more filters used, the more features are extracted.

Layer of Pooling
To minimize data space and processing time, CNN employs max pooling to replace output with a max summary. This enables you to identify the features that have the greatest influence while also reducing the risk of overfitting. It reduces the quantity of data generated by the convolutional layer for each feature while keeping the most important data.

Layer of Rectified Linear Unit (ReLU)
We can use Rectified Linear Unit after each convolutional and max pooling procedure (ReLU). For values x>0, the ReLU function simulates our neuron activations on a "large enough stimulus" to produce nonlinearity and returns 0 if it fails to match the criteria. This strategy has proven successful in resolving decreasing gradients. After the ReLU activation function, very small weights will remain 0.

Layer that is Fully Connected
Finally, to serve the convolutional and max pooling feature vector outputs, we'll utilize a fully connected layer (FCL). It converts high-resolution filtered photos into categories with labels.

*Here is an Example of Build CNN: *

def build_model(backbone, lr=1e-4):
    model = Sequential()
    model.add(backbone)
    model.add(Conv2D(16, (3, 3), padding="valid", activation="relu"))
    model.add(MaxPooling2D(pool_size=(2, 2),strides=(1, 1), padding="same"))
    model.add(Conv2D(32, (3, 3), padding="valid", activation="relu"))
    model.add(MaxPooling2D(pool_size=(2, 2),strides=(1, 1), padding="same"))
    model.add(Conv2D(64, (3, 3), padding="valid", activation="relu"))
    model.add(MaxPooling2D(pool_size=(2, 2),strides=(1, 1), padding="same"))
    model.add(Flatten())
    model.add(layers.Dropout(0.5))
    model.add(layers.BatchNormalization())
    model.add(layers.Dense(2, activation='softmax'))
Enter fullscreen mode Exit fullscreen mode

In this example, the model is made up of layers such as convolutional layers, pooling layers, and fully linked layers. The code you gave constructs a CNN model with three convolutional layers and three pooling layers. The last layer is a completely linked layer that has two neurons and a softmax activation function. The purpose of this model is to classify images into two classes.

CONCLUSION
Convolutional neural networks (CNNs) have completely changed the way that image processing and computer vision are practised. CNNs have emerged as the preferred method for a variety of visual identification applications due to their capacity to efficiently learn and extract useful features from pictures. Convolutional Neural Networks have made substantial contributions to computer vision and are still advancing technologies in augmented reality, medical imaging, and driverless cars. CNNs are likely to change and apply to new fields with continued research and development, stretching the limits of visual comprehension and recognition.

Top comments (0)