Convolutional Neural Network (CNN)

Convolutional Neural Network
Azure Data

Share Post Now :

HOW TO GET HIGH PAYING JOBS IN AWS CLOUD

Even as a beginner with NO Experience Coding Language

Explore Free course Now

Table of Contents

Loading

Machine learning is a subset of Artificial Intelligence. It tells us something unique about our data without writing a bunch of code specific to the problem. We just feed our data in the Azure Machine Learning service. In this blog, we will cover the basics of the Convolutional Neural Network (CNN) and how we train our CNN’s model on Azure ML service without knowing to code.

Why Azure ML Service?

  • In today’s scenario, many companies struggle to adopt the ML solution because data engineers face slow training and complex deployment. Azure ML service removes those barriers.
  • Azure ML service is a powerful drag and drop interface. where we go from idea to deployment in a few clicks without additional setup required.

Also Read : Our Blog Post To Know About Most Important  DP-100 FAQ

Overview Of Convolutional Neural Network (CNN)

  • We mostly use CNN’s in Computer Vision for Image Classification, object detection, and Neural Style Transfer.

 CV.

  • Problem: Images can be big. with 1000 hidden units we need a lot of space.
  • Solution: Use CNN’s, it’s like scanning over your image with a filter.

Also check: Azure Free Exam Voucher in Microsoft Ignite 2020

What Are Convolutional Neural Networks (CNNs)

  • CNN’s are a specific type of artificial neural network.
  • CNN’s works well with matrix inputs, such as images.
  • There are various kinds of the layer in CNN’s: convolutional layers, pooling layers, Dropout layers, and Dense layers.
  • CNN’s real-world applications: Detecting Handwritten Digits, AI-based robots, virtual assistants, NLP, Electromyography recognition, Drug discovery, Time series forecasting, and self-driving cars.

Do Check:  What is the difference between Data Science vs Data Analytics.

Image of CNN's Layers

Convolution Layer 

  • In CNN’s we use Convolutional layers which consist of a set of learnable filters and these filters are applied to a subregion of the input image to reduce image dimensions.
  • Ensure the spatial relationship between pixels.

Also Read Our Blog Post  On MLOps For An Overview.

 image of convolution-layer.

Pooling Layer

  • We use a pooling layer in CNN’s to reduce the number of dimensions(width, height) but retains the most important information. A common technique we use is Max Pooling.
  • Max pooling is a type of non-linear sampling. it will divide the input image into set non-overlapping rectangles.
  • Speed up Computation.
  • Makes some of the detected features more robust.

 Image of Pooling Layer.

To Know More About Automated Machine Learning click here.

Dropout Layer

  • We prefer Dropout layers in CNN’s to prevent overfitting by increasing testing accuracy.
  • We generally place the dropout layer with p = 0.5 in between fully connected layers.
  • …….CONV => Relu => Pool => FC => DO => FC => DO => FC……. Image of Dropout layer.

Also Read : Our Blog Post on Azure Machine Learning Model.

Fully-Connected Layer

  • In CNN’s Fully Connected Layer neurons are connected to all activations in the previous layer to generate class predictions.
  • it’s common to use more than one fully connected layer prior to applying the classifier.

 Image of Fully Connected Layer.

Rules Of Thumb

  1. The input layer should be square. Common size includes 32×32, 64×64, 96×96, 224×224.
  2. The input layer divisible by two multiple times after the first convolution layer is applied.
  3. Convolutional layers size such as 3×3 and 5×5 mostly.
  4. CNN used the POOL layer rather than the Convolutional layer for reducing spatial dimension until you have more exp on Convolutional Neural Networks architectures.

Also Check: Our blog post on the Microsoft dp 100 Exam

Azure ML Workspace

1)we need to install Azure ML extensions for the Azure CLI. Run the following cmd.

$ az extension add -n azure-cli-ml

2)now we will be able to use extension using az ml cmd.

3)we create a new resource group for the azure ML workspace. Run the following cmd.

$ az group create -n ml -l westus2
$ az ml workspace create -w mldws -g ml

4) we will change to working dir in our shell & export an azure ML workspace config to disk.

$ az ml folder attach -w mlws -g ml -e mls

5) Then we will install python ext to interact with our azure ML from within python. Run this cmd.

python3 -m pip install azure-cli azureml-sdk

  • now we run our authoring environment in the cloud, we can simply navigate to our Machine Learning workspace in Azure and open the Azure Machine Learning interface to use the Notebook viewer provided there. Screenshot of notebooks.
  • To run our code in this env then click on compute and create compute instance. when it will be done then we have an option to start Jupyter notebook. Screenshot of jupyter notebook

 

6) now we can load workspace config from this file without explicitly specifying the workspace and subscription in every experiment. we run the following code to load our workspace.

from azureml.core import Workspace
ws = Workspace.from_config()

Also Check Our Blog Post On Hyperparameter Tuning For an Overview.

Training A Convolutional Neural Networks On Azure 

  • Login to Azure portal with email ID (Azure user credential) which you used during creating Azure account. Screenshot of Azure login page
  • Now see the upper-left corner of the Azure portal, select Create a resource. Screenshot of select create
  • Now search Machine Learning and select Machine Learning then select Create. Screenshot of search ML.
  • Go to Azure Notebooks & then Create a new project.
  • Then download “CNN_Keras_Azure.ipynb” from here & upload it to your project.
  • Ensure “Running on Free Compute” is enabled. Screenshot of azure notebook.

Note:  Do Check Our Blog Post To Get An Overview About DP-900 vs DP-100 vs DP-200 vs DP-201.

  • Click Download config.json from the Overview section and then Upload config.json in your project folder and then launch option in Azure ML workspace.
  • Now Click on CNN_Keras_Azure.ipynb in your project to open & execute points by points.

This is how we train the convolutional neural network model on Azure with Keras.

Also Read: Our blog post on DP 100 Exam questions and Answers. Click here

Convolutional Neural Network Architecture 

Convolutional Neural Network (CNN) architecture is designed to process grid-like data such as images. It consists of three key layers: convolutional layers, which extract features like edges or textures; pooling layers, which reduce spatial dimensions and computational complexity; and fully connected layers, which classify the features into outputs. Advanced architectures include additional components like dropout layers to prevent overfitting and batch normalization for faster convergence. CNNs are widely used in image recognition, object detection, and natural language processing, with architectures like AlexNet, VGG, and ResNet setting benchmarks for deep learning advancements.

Convolutional Neural Network in Deep Learning

Convolutional Neural Networks (CNNs) are a specialized type of deep learning model designed for processing structured grid data, such as images. They excel in extracting spatial features by using convolutional layers, pooling layers, and fully connected layers. CNNs work by applying filters to detect patterns like edges, textures, or shapes in images, making them ideal for tasks like image classification, object detection, and facial recognition. Their ability to handle large-scale image data has revolutionized fields such as healthcare (e.g., tumor detection), autonomous driving, and augmented reality, offering unparalleled accuracy and efficiency in deep learning applications.

Convolutional Neural Network Example

A classic example of a Convolutional Neural Network (CNN) is its application in image classification tasks, such as identifying handwritten digits using the MNIST dataset. In this scenario, the CNN takes an input image, processes it through layers like convolutional layers (to extract features such as edges or patterns), pooling layers (to reduce dimensionality), and fully connected layers (to make predictions). The model learns to distinguish between digits (0-9) with high accuracy. Beyond MNIST, CNNs are widely used in facial recognition, medical imaging, and object detection tasks, demonstrating their power in processing visual data effectively.

FAQs

How do CNNs contribute to advancements in deep learning and machine learning?

Convolutional Neural Networks (CNNs) revolutionize deep learning and machine learning by excelling in image and video processing, enabling advancements in computer vision tasks like object detection, recognition, and classification.

What are the differences between traditional multilayer perceptrons and CNNs in processing image data?

Traditional multilayer perceptrons (MLPs) treat image data as flat vectors, losing spatial structure, while convolutional neural networks (CNNs) preserve spatial relationships using filters, making them more effective for image processing.

How do CNNs handle segmentation tasks in image processing?

Convolutional Neural Networks (CNNs) handle image segmentation tasks by using specialized architectures like U-Net or Mask R-CNN, which classify each pixel, dividing images into meaningful regions effectively.

How have CNN architectures evolved since AlexNet, and what are some examples of modern architectures?

Since AlexNet's breakthrough, CNN architectures have evolved with innovations like deeper layers (VGG), residual connections (ResNet), and attention mechanisms (EfficientNet), improving efficiency and accuracy for complex tasks.

What is the process of fine-tuning pre-trained CNN models for specific image data?

Fine-tuning pre-trained CNN models involves replacing or adjusting the final layers to match the target dataset, freezing earlier layers, and retraining with specific image data to optimize performance.

How does a CNN work with grayscale and RGB images?

A CNN processes grayscale images as single-channel inputs, while RGB images are treated as three-channel inputs. It extracts features like edges, textures, and patterns through convolutional layers for image analysis.

What roles do hyperparameters, optimization techniques, and regularization methods play in training CNN models?

Hyperparameters control model architecture and training dynamics, optimization techniques minimize loss functions efficiently, and regularization methods like dropout prevent overfitting, ensuring robust performance in training CNN models.

Related/References:

Next Task: Enhance Your Azure AI/ML Skills

Ready to elevate your Azure AI/ML expertise? Join our free class and gain hands-on experience with expert guidance.

Register Now: Free Azure AI/ML-Class

Take this opportunity to learn from industry experts and advance your AI career. Click the image below to enroll:

Picture of mike

mike

I started my IT career in 2000 as an Oracle DBA/Apps DBA. The first few years were tough (<$100/month), with very little growth. In 2004, I moved to the UK. After working really hard, I landed a job that paid me £2700 per month. In February 2005, I saw a job that was £450 per day, which was nearly 4 times of my then salary.