Neural Networks - Multi-class classification
摘要: 本文是吴恩达 (Andrew Ng)老师《机器学习》课程,第九章《神经网络学习》中第71课时《多分类》的视频原文字幕。为本人在视频学习过程中记录下来并加以修正,使其更加简洁,方便阅读,以便日后查阅使用。现分享给大家。如有错误,欢迎大家批评指正,在此表示诚挚地感谢!同时希望对大家的学习能有所帮助.
————————————————
In this video, I want to tell you about how to use neural networks to do multi-class classification, where we may have more than one category that we’re trying to distinguish amongst. In the last part of the last video, where we had the handwritten digit recognition problem, that was actually a multi-class classification problem, because there were 10 possible, for recognizing the digits from 0 to 9. And so, here I wanna fill you in on the detail of how to do that.
The way we do multi-class classification in a neural network is essentially an extension of the one-versus-all method. So, let’s say we have a computer vision example, where instead of just trying to recognize cars as in the original example that I started off with, but let’s say that we’re trying to recognize four categories of objects. So given an image, we want to decide if it is a pedestrian, a car, a motorcycle, or a truck. If that’s the case, what we would do is we would build a neural network with four output units. So that our neural network now outputs a vector of 4 numbers. So, the output now is actually going to be a vector of 4 numbers. And what we’re going to try to do is get the first output unit to classify is the image of a pedestrian, yes or no. The second unit to classify is the image of a car, yes or no. The third unit to classify is the image of a motorcycle, yes or no. And the fourth unit would classify is the image of a truck, yes or no. And thus, when the image is of a pedestrian, we would ideally want the network to output 1,0,0,0. When it is a car we want it to output 0,1,0,0. When this is a motorcycle, we get it to or rather we want it to output 0,0,1,0 and so on. So this is just like the one-versus-all method that we talked about when we were describing logistic regression. And here we have essentially 4 logistic regression classifiers, each of which is trying to recognize one of the four classes that we want to distinguish amongst.
So, rearranging the slide of it. Here’s our neural network with 4 output units, and those are what we want to be when we have the different images. And the way we’re going to represent the training set in these settings is as follows. So, when we have a training set with different images of pedestrians, cars, motorcycles and trucks, what we’re going to do in this example is that whereas previously we had written out the labels as y being an integer from 1, 2, 3 or 4. Instead of representing y this way we’re going to instead represent y as follows: namely
will be either
or
or
or
depending on what the corresponding image
is. And so one training example will be one pair
, where
is an image of one of the four objects, and
will be one of these vectors. And hopefully, we can find a way to get our neural networks to output some value. So, the
is approximately y. And both
and
, both of these are going to be, in our example, 4 dimensional vectors when we have 4 classes. So, that is how you get the neural network to do multi-class classification.
This wraps our discussion on how to represent Neural Networks that is on our hypotheses representation. In the next set of videos, let’s start to talk about how to take a training set and how to automatically learn the parameters of the neural networks.
<end>