使用MATLAB的深度学习:在11行MATLAB代码中深度学习
来自该系列:与Matlab深入学习
Watch a quick demonstration of how to use MATLAB®,一个简单的网络摄像头和一个深层神经网络,可识别周围环境中的对象。此演示使用Alexnet, a pretrained deepconvolutional neural network(CNN或Convnet)已接受超过一百万张图像的培训。
The example has two parts: setting up the camera and performing object recognition. The first part shows how to use the摄像头
command to acquire images from the camera. Using the绘制
命令,MATLAB能够连续更新和显示相机拍摄的图像。
The second part illustrates how to download a pretrained deep neural network called AlexNet and use MATLAB to continuously process the camera images. AlexNet takes the image as input and provides a label for the object in the image. You can experiment with objects in your surroundings to see how accurate AlexNet is.
Today you can do this very easily with MATLAB, but even just a few years ago it would have been considered science fiction.
学习更多关于与Matlab深入学习或者download the demo code.
记录:2016年12月6日
你好。我叫乔·希克林。我是Mathworks的高级开发人员。我一直在使用MATLAB和神经网络工具箱进行深度学习。我写了一个简单的小程序,可以做一些很酷的事情。我想现在向您展示。
What I've done is I've taken a webcam and attached it to a neural net that recognizes images. Now I can point the webcam at various objects and it recognizes it. A corkscrew, or maybe a screwdriver, or perhaps a revolver, a harmonica, a teapot, a shovel, that sort of thing. It's not perfect, but it does a pretty good job.
So let's look at the code that does this. This is the whole program, right? It's just 11 lines. We're going to go through it. But we're going to do it in three separate stages.
We're going to clear the workspace. We're going to ask the camera to connect to the webcam, have the camera and take a picture, and then finally, show that picture on the screen. So when we run this we should get a fresh picture going on here. And that's the picture we just took.
但这是一个静止的图像。我们希望这是一个连续的视频。因此,我们将添加三行以将其循环。
We'll put a while loop around the code that's taking the picture. And we'll add a drawnow so MATLAB draws immediately. When I run this, we'll get the same thing. But now, it's a live video.
Finally, we need to add in the neural net. I'm using a network called AlexNet. AlexNet is a large deep convolutional neural net. They train this network on over a million images. And it can recognize about 1,000 different objects.
我已经下载了。现在我们准备好使用它了。这条线将要求网络对我们刚刚拍摄的图片进行分类。因此,我们将每张图片传递到网络,它将返回该图片的标签。
Before we do that, we have to resize the picture to the size that AlexNet expects. It was trained on a particular size of image. Finally, I'm going to use that label in the title of my picture. And I've got to convert it to a string with this command right here.
So we're all set. Those are the lines. Let's run it again. And we're running again.
I can recognize a keyboard, or maybe a space bar. Recognize my mouse, or maybe it's a spatula. And there we go.
我希望该计划的简单性鼓励您尝试深度学习。下一个自然的步骤是尝试转移学习。转移学习是您采用Alexnet等网络的地方,并在您自己的特定图像上重新训练了最后几层。对于您的特定图像,这将导致网络比Alexnet更好。如果您有兴趣了解有关如何将深度学习应用于问题的更多信息,请查看描述中的链接。
选择一个网站
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select:.
您还可以从以下列表中选择一个网站:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
美洲
- AméricaLatina(Español)
- 加拿大(英语)
- 美国(英语)