Don’t end with a “topic” – Start using deep learning in MATLAB

From “topic” to “practical” – what is deep learning?

Efforts to utilize the results of deep learning in corporate activities are becoming active. As the development of tools by vendors has progressed, it has become easier for general companies to use the results of deep learning.

neural networkA neural network is a mathematical model of nerve cells (neurons) that is applied to a learner. When the excitement state is transmitted, the potential level of the neuron rises, and when the threshold value is exceeded, the neuron fires itself and transmits the excitement state to the next neuron.What was conceived with the intention of mathematically simulating the movement of these neurons is connected to the current deep neural networks.

In the past, when using machine learning technology to perform various recognition and automatic classification, a major issue was how to extract effective features from the target data. Before the advent of deep learning, humans searched for the feature extraction part by trial and error, which required considerable knowledge and technology, and required enormous man-hours.

On the other hand, in deep learning, this feature extraction part can be learned from the data. The big difference is that you can learn with data without human intervention. In particular, in the “convolutional neural network (CNN)”, which has been attracting attention in recent years, the accuracy is improved in a task called image category recognition by stacking layers such as a convolutional layer, a pooling layer, and a regularization layer to form a deep network. We have succeeded in dramatically improving it.

In deep learning, feature extraction can also be learned from data.Until now, humans have been searching through trial and error, but now it is possible to learn with data without human intervention.

This convolutional neural network can be said to be a representative of deep learning at present, and even in the international competition “ILSVRC” that works to improve the accuracy of image recognition by computers, the convolutional neural network that appeared in 2012 has the error rate up to that point. It surprised researchers around the world by breaking records by more than 10 points.

reference:Working to reduce traffic accidents through deep learning research and development – ​​Denso IT Laboratory

Since then, the movement toward practical use of this technology has been accelerating, and one of the frameworks for that purpose is the integrated development environment for scientific computing provided by MathWorks introduced in this paper. There is a “MATLAB”.

With MATLAB, deep learning is available in just minutes

MATLAB has a mechanism called a toolbox that allows you to add commands and libraries to enhance its functionality. One of the toolboxes related to machine learning, “Neural Network Toolbox,” supports various methods such as two-layer neural networks and self-organizing mapping that have been used for classification and regression.

In particular, from R2016a released in 2016, algorithms such as “Convolutional Neural Network (CNN)”, “Recurrent Neural Network”, and “Stacked Autoencoders” have also been added. , Deep learning can be easily utilized by any organization.

Diagram provided by deep learning of MATLAB (R2016a or later). The Neural Network Toolbox makes deep learning easy to use.The feature is that it can be used immediately after installation and has extensive support.

With MATLAB, you can use it as soon as you install the Neural Network Toolbox, and you can develop applications that utilize image recognition in minutes. In the latter half of this article, we will also introduce the development of “an application that uses deep learning to identify what kind of object was captured by a camera in a specific time using a PC and a webcam” using MATLAB, so please refer to it. I want you to.

Utilizing the results of convolutional neural networks in “transfer learning”

Deep learning, which I mentioned earlier that “it can be developed in a few minutes,” is usually quite difficult to develop an application that utilizes deep learning in just a few minutes due to the need to train using a huge amount of data. For example, in the competition called ILSVRC mentioned earlier, 1000 images are prepared for each category in order to recognize objects in 1000 categories, and a high-performance GPU is used for learning such a large number of images. Even if you use it, it is said that it will take several days.

When a company develops a new application or research and development, it takes time and effort to prepare such a large amount of image data and train a convolutional neural network from scratch, so that anyone can try it. It will not be a thing. Therefore, a method called “transfer learning” was devised.

Transfer learningTransfer learning refers to a method of diverting a learned network to another task.This is a method of using a convolutional neural network trained using a large number of images as an image feature extractor and combining it with a new classifier to use it for a new classification task.

In this transfer learning, a neural network that has been trained with a large number of images in advance is prepared. For example, prepare a network called Alex Net, which won the 2012 ILSVRC. And if it becomes necessary to categorize images of dogs and cats, instead of training the convolutional neural network from scratch, divert this Alex Net to this task. In other words, by using this network to extract features from images and combining them with a new classifier, it is possible to avoid learning a convolutional neural network from scratch. The classifier made in this way has the advantage that the performance is relatively high and the amount of calculation for learning is small.

Convolutional neural network and transfer learning. Transfer learning is a method of diverting a learned network to another task.It is said that it is easy to calculate and has high performance because it only needs to be learned with the newly attached classifier.

Generally, when performing image recognition by debrazing, a huge number of images and a high-performance GPU are indispensable, but by applying the transfer learning method, such trouble and cost should be avoided. Is possible. For natural images that look like they were taken with a camera, you can easily create a high-performance image recognition system in this way.

For example, the classification of “dandelions” and “coltsfoot”, which are very similar at first glance, can be easily realized by using this transfer learning.

An application example using transfer learning.Transfer learning is performed using a convolutional neural network as a feature extractor to distinguish between dandelions and coltsfoot, which are difficult for the human eye to distinguish.

In terms of classifying images that are difficult for the human eye to distinguish, application to medical images is also conceivable. The image below is a microscopic image of blood infected with infectious diseases such as malaria, trypanosomiasis, and babesiosis, and classification of such images can be easily realized by using this transfer learning.

Application example to medical images.Uses metastasis learning to identify infectious diseases such as malaria, trypanosomiasis, and babesiosis

Furthermore, it is also being used in the manufacturing and retail industries. Image recognition related to autonomous driving is especially common in the manufacturing industry these days. Image recognition has a wide range of applications, such as recognizing white lines on the road to control driving, measuring the distance between vehicles, and measuring obstacles in front and behind. In the retail industry, it is used to grasp the number of visits to stores, the flow lines of customers in stores, and the movement of eyes on display shelves. By advancing the learning, it becomes possible to more accurately recognize and grasp the image.

Application examples of image recognition have the potential to expand significantly in the future depending on the idea. Convolutional neural networks and transfer learning have become powerful tools to support such businesses.

MATLAB’s strengths in utilizing deep learning

As mentioned above, MATLAB brings various benefits to the business utilization of deep learning. One of the major features is that it is easy to link with various devices and is easy to use. And the point is that the toolboxes for developing various applications including deep learning are integrated.

For example, consider developing an application that uses a PC and a webcam to identify what an object is in the camera at a particular time. There are various things that can be seen by the camera, such as telephones, smartphones, lighting, people, and cats.

In general, it is necessary to develop camera control, video analysis, statistical processing, deep learning, and so on. But with MATLAB, “Neural Network Toolbox” for neural networks, “Computer Vision System Toolbox” for video analysis, “Image Processing Toolbox” for image processing, and “Statistics and Machine” for statistics and machine learning. You can easily develop an application just by installing “Learning Toolbox” and calling it from the code.

Actually, when calling a trained convolutional neural network called ImageNet, specify as follows. You can see that it can be developed with a simple specification.

convnet =helperImportMatConvNet('imagenet-caffe-alex.mat');

In this, the information of the neural network trained with a large amount of image data is aggregated. The image database has 1000 categories, and each category consists of 1000 or more images. It can be used as a convnet.

Next, if you do the following, you can make this neural network recognize the image in the variable “im”, and you can get the recognition result with the variables “Ypred” and “score”.

[Ypred, score] = classify(convnet, im_);

Also, when importing the image of the object transferred from the Web camera image as im, you can do as follows.

wcam = webcam;
im = snapshot(wcam);

Part of the toolbox provided by MATLAB

The acquired data can also be statistically processed together with the date and time and the object name. From image acquisition to image recognition using deep learning can be achieved in just a few lines.

In MATLAB, various analyzes can be performed smoothly by linking toolboxes in this way. There are about 90 toolboxes, and you can flexibly combine the appropriate ones according to what kind of application you want to create.

It is easy to link with hardware as well as software. For example, it is possible to acquire sensor data in combination with Rasberry Pi, or acquire 3-axis acceleration data and gyro data from iOS by streaming.

By preparing a support page where you can browse various documents and File Exchange where you can use abundant sample code including user posts, you can start the necessary work immediately even if you are using MATLAB for the first time.

MATLAB is already a long-established tool in the field of manufacturing. The goodness of MATLAB, such as the abundance of information on the website, the extensive community, and the generous support of staff with experience as engineers, can be utilized in deep learning efforts as it is. It is easy to use even for beginners, and I want you to make good use of it in your business as a product that supports cutting-edge technologies such as convolutional neural networks.

Related Sites

Webinar: Deep Learning with MATLAB

Explanation: Machine learning with MATLAB

(Mynavi News Advertising Planning: Provided by MathWorks Japan)

[PR]Provided by: