MATLAB Deep Learning | Part One | Classification
1. Introduction to Deep learning |Source: MathWorks| Retrieved: Sept 10,2019|
What Is Deep Learning?Deep learning is a branch of machine learning that teaches computers to do what comes naturally to humans: learn from experience. Machine learning algorithms use computational methods to “learn” information directly from data without relying on a predetermined equation as a model. Deep learning is especially suited for image recognition, which is important for solving problems such as facial recognition, motion detection, and many advanced driver assistance technologies such as autonomous driving, lane detection, pedestrian detection, and autonomous parking.
Deep Learning Toolbox™ provides simple MATLAB® commands for creating and interconnecting the layers of a deep neural network. Examples and pre-trained networks make it easy to use MATLAB for deep learning, even without knowledge of advanced computer vision algorithms or neural networks.
Deep learning uses neural networks to learn useful representations of features directly from data. Neural networks combine multiple nonlinear processing layers, using simple elements operating in parallel and inspired by biological nervous systems. Deep learning models can achieve state-of-the-art accuracy in object classification, sometimes exceeding human-level performance.
You train models using a large set of labeled data and neural network architectures that contain many layers, usually including some convolutional layers. Training these models is computationally intensive and you can usually accelerate training by using a high performance GPU. The diagram below shows how Convolutional Neural Networks combine layers that automatically learn features from many images to classify new images.
Many deep learning applications use image files, and sometimes millions of image files. To access many image files for deep learning efficiently, MATLAB provides the imageDatastore function. Use this function to:
- Automatically read batches of images for faster processing in machine learning and computer vision applications
- Import data from image collections that are too large to fit in memory
- Label your image data automatically based on folder names.
2. Deep learning | Project #1 | Object Classification
In this project, we will use a pre-trained Neural Network (CNN) to classify different objects. We will connect a web camera to our laptop, load a pre-trained CNN, continuously take pictures, resize the pictures and finally classify an object based on the selected CNN, in our case GoogLeNet. Using the pre-trained CNNs like GoogLeNet or Alexnet, some basic objects, like water bottle or a computer mouse can be easily classified with a higher accuracy as shown in the figure below.
In this instance, the water bottle is predicted with an accuracy of 99.1%. However, If we try to classify an apple, for example, the prediction accuracy will be much lower and there is a higher prediction confusion as a Pear or Pomegranate in lieu of the apple. This prediction confusion can be mitigated by creating a new Data Store of images related to our problem and by re-training the CNN with the new images (this process aka transfer learning).
Refer to Project Two to learn more about Transfer Learning.
For this project we need:
-Deep Learning Toolbox
-Pre-trained convolutional neural network, CNN
Deep Learning in MATLAB
1. Download Deep Learning Toolbox from MathWorks website
2. Download Neural Networks like Alexnet, Googlenet … etc.
3. Open MATLAB
4. Connect the webcam to your computer
5. Run these commands to connect to the webcam and create a CNN object.
camera = webcam; % Connect to the camera
6. Run the following code to show and classify live images.
Position an object in front the web cam and the neural network will classify the object into its label and will also give you predicted accuracy. It will keep classifying images until you press Ctrl+C. The code resizes the image for the network using imresize.
3. Deep learning Video - Project # 1 | Classification
Below is a complete video demonstration of the deep learning project #1, that is an extension of the tutorial above.
From the project video, we can conclude that using an existing CNN will not solve every problems. According to MathWorks, most of the pre-trained CNNs are trained over a million images and can classify over a thousand categories. Likewise, it is easier to use a pre-trained CNN than training a CNN from scratch. However, these CNNs cannot classify every image unless we do a transfer learning and re-train the network for the specific problem we have. Therefore, we have to perform a transfer learning create our own CNN based on an existing one.
Please refer to Part Two to learn more about Transfer Learning.
»»» END of Deep Learning Part One »»»