5.10 Mult-label Classification | Classification with multiple outputs (Optional) --[ML | Andrew Ng]
 You've learned about multi-class classification, where the output label y can be any one of two or potentially many more than two possible categories. There's a different type of classification problem called a multi-label classification problem, which is where, associated with each image, there could be multiple labels. Let me show you what I mean by that. If you're building a self-driving car or maybe a driver assistance system, then given a picture of what's in front of your car, you may want to ask the question, like, is there a car or at least one car, or is there a bus, or is there a pedestrian, or are there any pedestrians? In this case, there is a car, there is no bus, and there is at least one pedestrian, or in this second image, no cars, no buses, and yes pedestrians, and yes car, yes bus, and no pedestrians. So these are examples of multi-label classification problems because associated with a single input image x are three different labels corresponding to whether or not there are any cars, buses, or pedestrians in the image. So in this case, the target output y is actually a vector of three numbers, and this is as distinct from multi-class classification where, for, say, handwritten digit classification, y was just a single number even if that number could take on 10 different possible values. So how do you build a neural network for multi-label classification? One way to go about it is to just treat this as three completely separate machine learning problems. You could build one neural network to decide are there any cars, a second one to detect buses, and a third one to detect pedestrians, and that's actually not an unreasonable approach. Here's the first neural network to detect cars, second one to detect buses, third one to detect pedestrians, but there's another way to do this, which is to train a single neural network to simultaneously detect all three of cars, buses, and pedestrians, which is if your neural network architecture looks like this. That's your input x. First hidden layer outputs a1, second hidden layer outputs a2, and then the final output layer in this case will have three output neurons and will output a3, which is going to be a vector of three numbers. And because we're solving three binary classification problems, so is there a car, is there a bus, is there a pedestrian, you can use a sigmoid activation function for each of these three nodes in the output layer. And so a3 in this case will be a31, a32, and a33 corresponding to whether or not the learning algorithm thinks there's a car and or a bus and or pedestrians in the image. So multi-class classification and multi-label classification are sometimes confused with each other. And that's why in this video I want to share with you just a definition of multi-label classification problems as well so that depending on your application, you could choose the right one for the job you want to do. So that's it for multi-label classification. I find that sometimes multi-class classification and multi-label classification are confused with each other, which is why I wanted to explicitly in this video share with you what is multi-label classification so that depending on your application, you can choose the right two for the job that you want to do. And that wraps up this section on multi-class and multi-label classification. In the next video, we'll start to look at some more advanced neural network concepts, including an optimization algorithm that is even better than gradient descent. So let's take a look at that algorithm in the next video because it'll help you to get your learning algorithms to learn much faster. So let's go on to the next video.
[{"start": 0.0, "end": 9.28, "text": " You've learned about multi-class classification, where the output label y can be any one of"}, {"start": 9.28, "end": 13.280000000000001, "text": " two or potentially many more than two possible categories."}, {"start": 13.280000000000001, "end": 19.2, "text": " There's a different type of classification problem called a multi-label classification"}, {"start": 19.2, "end": 25.92, "text": " problem, which is where, associated with each image, there could be multiple labels."}, {"start": 25.92, "end": 28.16, "text": " Let me show you what I mean by that."}, {"start": 28.16, "end": 34.4, "text": " If you're building a self-driving car or maybe a driver assistance system, then given a picture"}, {"start": 34.4, "end": 40.32, "text": " of what's in front of your car, you may want to ask the question, like, is there a car"}, {"start": 40.32, "end": 47.36, "text": " or at least one car, or is there a bus, or is there a pedestrian, or are there any pedestrians?"}, {"start": 47.36, "end": 54.879999999999995, "text": " In this case, there is a car, there is no bus, and there is at least one pedestrian,"}, {"start": 54.88, "end": 63.040000000000006, "text": " or in this second image, no cars, no buses, and yes pedestrians, and yes car, yes bus,"}, {"start": 63.040000000000006, "end": 65.16, "text": " and no pedestrians."}, {"start": 65.16, "end": 72.32000000000001, "text": " So these are examples of multi-label classification problems because associated with a single"}, {"start": 72.32000000000001, "end": 81.52000000000001, "text": " input image x are three different labels corresponding to whether or not there are any cars, buses,"}, {"start": 81.52000000000001, "end": 84.18, "text": " or pedestrians in the image."}, {"start": 84.18, "end": 92.68, "text": " So in this case, the target output y is actually a vector of three numbers, and this is as"}, {"start": 92.68, "end": 99.32000000000001, "text": " distinct from multi-class classification where, for, say, handwritten digit classification,"}, {"start": 99.32000000000001, "end": 105.2, "text": " y was just a single number even if that number could take on 10 different possible values."}, {"start": 105.2, "end": 110.16000000000001, "text": " So how do you build a neural network for multi-label classification?"}, {"start": 110.16, "end": 114.96, "text": " One way to go about it is to just treat this as three completely separate machine learning"}, {"start": 114.96, "end": 115.96, "text": " problems."}, {"start": 115.96, "end": 120.64, "text": " You could build one neural network to decide are there any cars, a second one to detect"}, {"start": 120.64, "end": 127.16, "text": " buses, and a third one to detect pedestrians, and that's actually not an unreasonable approach."}, {"start": 127.16, "end": 132.88, "text": " Here's the first neural network to detect cars, second one to detect buses, third one"}, {"start": 132.88, "end": 138.51999999999998, "text": " to detect pedestrians, but there's another way to do this, which is to train a single"}, {"start": 138.52, "end": 145.68, "text": " neural network to simultaneously detect all three of cars, buses, and pedestrians, which"}, {"start": 145.68, "end": 149.52, "text": " is if your neural network architecture looks like this."}, {"start": 149.52, "end": 150.92000000000002, "text": " That's your input x."}, {"start": 150.92000000000002, "end": 156.8, "text": " First hidden layer outputs a1, second hidden layer outputs a2, and then the final output"}, {"start": 156.8, "end": 163.72, "text": " layer in this case will have three output neurons and will output a3, which is going"}, {"start": 163.72, "end": 167.56, "text": " to be a vector of three numbers."}, {"start": 167.56, "end": 172.64000000000001, "text": " And because we're solving three binary classification problems, so is there a car, is there a bus,"}, {"start": 172.64000000000001, "end": 177.84, "text": " is there a pedestrian, you can use a sigmoid activation function for each of these three"}, {"start": 177.84, "end": 180.1, "text": " nodes in the output layer."}, {"start": 180.1, "end": 187.36, "text": " And so a3 in this case will be a31, a32, and a33 corresponding to whether or not the learning"}, {"start": 187.36, "end": 192.92000000000002, "text": " algorithm thinks there's a car and or a bus and or pedestrians in the image."}, {"start": 192.92, "end": 197.79999999999998, "text": " So multi-class classification and multi-label classification are sometimes confused with"}, {"start": 197.79999999999998, "end": 199.11999999999998, "text": " each other."}, {"start": 199.11999999999998, "end": 203.2, "text": " And that's why in this video I want to share with you just a definition of multi-label"}, {"start": 203.2, "end": 207.88, "text": " classification problems as well so that depending on your application, you could choose the"}, {"start": 207.88, "end": 210.92, "text": " right one for the job you want to do."}, {"start": 210.92, "end": 214.6, "text": " So that's it for multi-label classification."}, {"start": 214.6, "end": 220.32, "text": " I find that sometimes multi-class classification and multi-label classification are confused"}, {"start": 220.32, "end": 225.95999999999998, "text": " with each other, which is why I wanted to explicitly in this video share with you what"}, {"start": 225.95999999999998, "end": 231.64, "text": " is multi-label classification so that depending on your application, you can choose the right"}, {"start": 231.64, "end": 234.44, "text": " two for the job that you want to do."}, {"start": 234.44, "end": 240.6, "text": " And that wraps up this section on multi-class and multi-label classification."}, {"start": 240.6, "end": 245.84, "text": " In the next video, we'll start to look at some more advanced neural network concepts,"}, {"start": 245.84, "end": 250.68, "text": " including an optimization algorithm that is even better than gradient descent."}, {"start": 250.68, "end": 255.08, "text": " So let's take a look at that algorithm in the next video because it'll help you to get"}, {"start": 255.08, "end": 257.9, "text": " your learning algorithms to learn much faster."}, {"start": 257.9, "end": 276.96, "text": " So let's go on to the next video."}]