1
$\begingroup$

I'm working on CNN model and I used one hot vector type of labels. The number of classes is 3: [1,0,0], [0,1,0], [0,0,1].

net(x)

I'm getting such an output: [0.8439, 0.1355, 0.0757], which is obviously 1st class. The question: why a sum of values in this vector exceeds 1? Also, I got earlier even one negative value of those 3. On what it is depending and how to know what these "outputs" could be.

$\endgroup$

2 Answers 2

1
$\begingroup$

Here it's a mistake to one-hot-encode the class, because it turns the task into multi-label classification instead of regular multi-class classification. In your task an instance can only have a single class, so the class should be encoded as an int (for example with LabelEncoder).

This is why the predicted probabilities don't sum to 1, because in multi-label classification the classes are independent of each other. For example the output [0.9,0.4,0.7] means that class 1 label is predicted true at 90% and false at 10%, class 2 label is predicted true at 40% and false at 60%, class 3 label is predicted true at 70% and false at 30%. It wouldn't make sense to pick the maximum probability of the 3 classes in this scenario.

See also this answer.

$\endgroup$
0
$\begingroup$

I don't think Erwan's answer is correct about it being a mistake to one-hot encode the class. For multi-class classification, you should be using softmax and you should be encoding the label as a one-hot vector. Softmax will allow you to pick the single label which has the highest probability. If you are doing multi-label classification, where the sample can have multiple labels, you can use something like sigmoid, which will give you a probability for each class and each prediction is independent of the other predictions.

As for why your probabilities don't sum to one... You didn't mention which activation function you ended up using, if at all. If you used sigmoid, it could explain why your probabilities sum up to more than 1 because each result is independent of the other. But it doesn't explain why you got a negative value at one point. So my guess would be you aren't actually applying any activation function and you're looking at the raw outputs.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.