Convolutional Neural Network (CNN):
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.
Overview Of Convolutional Neural Network (CNN)
- We mostly use CNN’s in Computer Vision for Image Classification, object detection, and Neural Style Transfer.
- 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.
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.
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.
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.
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…….
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.
Rules Of Thumb
- The input layer should be square. Common size includes 32×32, 64×64, 96×96, 224×224.
- The input layer divisible by two multiple times after the first convolution layer is applied.
- Convolutional layers size such as 3×3 and 5×5 mostly.
- CNN used the POOL layer rather than the Convolutional layer for reducing spatial dimension until you have more exp on Convolutional Neural Networks architectures.
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.
- 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.
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()
Training A Convolutional Neural Networks On Azure
- Login to Azure portal with email ID (Azure user credential) which you used during creating Azure account.
- Now see the upper-left corner of the Azure portal, select Create a resource.
- Now search Machine Learning and select Machine Learning then select Create.
- 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.
- 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.